remove error_reporting() hacks; set default error reporting level in functions.php

This commit is contained in:
Andrew Dolgov 2010-11-10 13:14:44 +03:00
parent 55a5137307
commit fb0742394a
11 changed files with 16 additions and 78 deletions

View File

@ -1,6 +1,4 @@
<?php <?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
/* remove ill effects of magic quotes */ /* remove ill effects of magic quotes */
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
@ -16,23 +14,13 @@
$_REQUEST = array_map('stripslashes_deep', $_REQUEST); $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
} }
require_once "functions.php";
require_once "sessions.php"; require_once "sessions.php";
require_once "modules/backend-rpc.php"; require_once "modules/backend-rpc.php";
/* if ($_REQUEST["debug"]) {
define('DEFAULT_ERROR_LEVEL', E_ALL);
} else {
define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
}
error_reporting(DEFAULT_ERROR_LEVEL); */
require_once "sanity_check.php"; require_once "sanity_check.php";
require_once "config.php"; require_once "config.php";
require_once "db.php"; require_once "db.php";
require_once "db-prefs.php"; require_once "db-prefs.php";
require_once "functions.php";
no_cache_incantation(); no_cache_incantation();

View File

@ -1,10 +1,7 @@
<?php <?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require_once "sessions.php";
require_once "sanity_check.php";
require_once "functions.php"; require_once "functions.php";
require_once "sessions.php";
require_once "sanity_check.php";
require_once "config.php"; require_once "config.php";
require_once "db.php"; require_once "db.php";

View File

@ -1,6 +1,4 @@
<?php <?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require_once "functions.php"; require_once "functions.php";
require_once "sessions.php"; require_once "sessions.php";
require_once "sanity_check.php"; require_once "sanity_check.php";

View File

@ -1,10 +1,7 @@
<?php <?php
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
error_reporting(E_ALL & ~E_NOTICE);
if ($_REQUEST["debug"]) {
define('DEFAULT_ERROR_LEVEL', E_ALL);
}
require_once 'config.php'; require_once 'config.php';
@ -365,7 +362,7 @@
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch); $contents = @curl_exec($ch);
if ($contents === false) { if ($contents === false) {
curl_close($ch); curl_close($ch);
return false; return false;
@ -380,7 +377,7 @@
return $contents; return $contents;
} else { } else {
return file_get_contents($url); return @file_get_contents($url);
} }
} }
@ -485,8 +482,6 @@
# print "FAVICON [$site_url]: $favicon_url\n"; # print "FAVICON [$site_url]: $favicon_url\n";
error_reporting(0);
$icon_file = ICONS_DIR . "/$feed.ico"; $icon_file = ICONS_DIR . "/$feed.ico";
if ($favicon_url && !file_exists($icon_file)) { if ($favicon_url && !file_exists($icon_file)) {
@ -502,9 +497,6 @@
} }
} }
} }
error_reporting(DEFAULT_ERROR_LEVEL);
} }
function update_rss_feed($link, $feed, $ignore_daemon = false) { function update_rss_feed($link, $feed, $ignore_daemon = false) {
@ -611,10 +603,6 @@
_debug("update_rss_feed: fetching [$fetch_url]..."); _debug("update_rss_feed: fetching [$fetch_url]...");
} }
if (!defined('DAEMON_EXTENDED_DEBUG') && !$_REQUEST['xdebug']) {
error_reporting(0);
}
$obj_id = md5("FDATA:$use_simplepie:$fetch_url"); $obj_id = md5("FDATA:$use_simplepie:$fetch_url");
if ($memcache && $obj = $memcache->get($obj_id)) { if ($memcache && $obj = $memcache->get($obj_id)) {
@ -628,7 +616,7 @@
} else { } else {
if (!$use_simplepie) { if (!$use_simplepie) {
$rss = fetch_rss($fetch_url); $rss = @fetch_rss($fetch_url);
} else { } else {
if (!is_dir(SIMPLEPIE_CACHE_DIR)) { if (!is_dir(SIMPLEPIE_CACHE_DIR)) {
mkdir(SIMPLEPIE_CACHE_DIR); mkdir(SIMPLEPIE_CACHE_DIR);
@ -668,8 +656,6 @@
if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) { if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
_debug("update_rss_feed: fetch done, parsing..."); _debug("update_rss_feed: fetch done, parsing...");
} else {
error_reporting (DEFAULT_ERROR_LEVEL);
} }
$feed = db_escape_string($feed); $feed = db_escape_string($feed);
@ -1134,8 +1120,6 @@
$dupcheck_qpart = ""; $dupcheck_qpart = "";
} }
// error_reporting(0);
/* Collect article tags here so we could filter by them: */ /* Collect article tags here so we could filter by them: */
$article_filters = get_article_filters($filters, $entry_title, $article_filters = get_article_filters($filters, $entry_title,
@ -1153,8 +1137,6 @@
continue; continue;
} }
// error_reporting (DEFAULT_ERROR_LEVEL);
$score = calculate_article_score($article_filters); $score = calculate_article_score($article_filters);
if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) { if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
@ -2261,8 +2243,6 @@
function sanity_check($link) { function sanity_check($link) {
error_reporting(0);
$error_code = 0; $error_code = 0;
$schema_version = get_schema_version($link); $schema_version = get_schema_version($link);
@ -2281,8 +2261,6 @@
$error_code = 12; $error_code = 12;
} }
error_reporting (DEFAULT_ERROR_LEVEL);
if ($error_code != 0) { if ($error_code != 0) {
print_error_xml($error_code); print_error_xml($error_code);
return false; return false;
@ -2293,9 +2271,7 @@
function file_is_locked($filename) { function file_is_locked($filename) {
if (function_exists('flock')) { if (function_exists('flock')) {
error_reporting(0); $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r");
$fp = fopen(LOCK_DIRECTORY . "/$filename", "r");
error_reporting(DEFAULT_ERROR_LEVEL);
if ($fp) { if ($fp) {
if (flock($fp, LOCK_EX | LOCK_NB)) { if (flock($fp, LOCK_EX | LOCK_NB)) {
flock($fp, LOCK_UN); flock($fp, LOCK_UN);
@ -3232,7 +3208,7 @@
if (time() - $_SESSION["daemon_stamp_check"] > 30) { if (time() - $_SESSION["daemon_stamp_check"] > 30) {
$stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
if ($stamp) { if ($stamp) {
$stamp_delta = time() - $stamp; $stamp_delta = time() - $stamp;
@ -3256,7 +3232,7 @@
if (CHECK_FOR_NEW_VERSION && $_SESSION["access_level"] >= 10) { if (CHECK_FOR_NEW_VERSION && $_SESSION["access_level"] >= 10) {
if ($_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) { if ($_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
$new_version_details = check_for_update($link); $new_version_details = @check_for_update($link);
print "<param key=\"new_version_available\" value=\"". print "<param key=\"new_version_available\" value=\"".
sprintf("%d", $new_version_details != ""). "\"/>"; sprintf("%d", $new_version_details != ""). "\"/>";
@ -3950,18 +3926,15 @@
return; return;
} }
error_reporting(0);
if (DEFAULT_UPDATE_METHOD == "1") { if (DEFAULT_UPDATE_METHOD == "1") {
$rss = new SimplePie(); $rss = new SimplePie();
$rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT); $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT);
// $rss->set_timeout(MAGPIE_FETCH_TIME_OUT);
$rss->set_feed_url($fetch_url); $rss->set_feed_url($fetch_url);
$rss->set_output_encoding('UTF-8'); $rss->set_output_encoding('UTF-8');
$rss->init(); $rss->init();
} else { } else {
$rss = fetch_rss($releases_feed); $rss = fetch_rss($releases_feed);
} }
error_reporting (DEFAULT_ERROR_LEVEL);
if ($rss) { if ($rss) {
@ -5100,8 +5073,6 @@
$lnum = $limit*$offset; $lnum = $limit*$offset;
error_reporting (DEFAULT_ERROR_LEVEL);
$num_unread = 0; $num_unread = 0;
$cur_feed_title = ''; $cur_feed_title = '';
@ -6859,6 +6830,8 @@
$url = fix_url($url); $url = fix_url($url);
$baseUrl = substr($url, 0, strrpos($url, '/') + 1); $baseUrl = substr($url, 0, strrpos($url, '/') + 1);
libxml_use_internal_errors(true);
$doc = new DOMDocument(); $doc = new DOMDocument();
$doc->loadHTMLFile($url); $doc->loadHTMLFile($url);
$xpath = new DOMXPath($doc); $xpath = new DOMXPath($doc);

View File

@ -1,5 +1,4 @@
<?php <?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
define('DISABLE_SESSIONS', true); define('DISABLE_SESSIONS', true);
require "functions.php"; require "functions.php";

View File

@ -1,9 +1,7 @@
<?php <?php
error_reporting(E_ERROR | E_WARNING | E_PARSE); require_once "functions.php";
require_once "sessions.php"; require_once "sessions.php";
require_once "sanity_check.php"; require_once "sanity_check.php";
require_once "functions.php";
require_once "config.php"; require_once "config.php";
require_once "db.php"; require_once "db.php";
require_once "db-prefs.php"; require_once "db-prefs.php";

View File

@ -1,6 +1,4 @@
<?php <?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require_once "functions.php"; require_once "functions.php";
require_once "sessions.php"; require_once "sessions.php";
require_once "sanity_check.php"; require_once "sanity_check.php";

View File

@ -4,14 +4,11 @@
// 1) templates/register_notice.txt - displayed above the registration form // 1) templates/register_notice.txt - displayed above the registration form
// 2) register_expire_do.php - contains user expiration queries when necessary // 2) register_expire_do.php - contains user expiration queries when necessary
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$action = $_REQUEST["action"]; $action = $_REQUEST["action"];
require_once "sessions.php";
require_once "sanity_check.php";
require_once "functions.php"; require_once "functions.php";
require_once "sessions.php";
require_once "sanity_check.php";
require_once "config.php"; require_once "config.php";
require_once "db.php"; require_once "db.php";

View File

@ -1,6 +1,4 @@
<?php <?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require_once "functions.php"; require_once "functions.php";
require_once "sessions.php"; require_once "sessions.php";
require_once "sanity_check.php"; require_once "sanity_check.php";

View File

@ -1,18 +1,15 @@
#!/usr/bin/php #!/usr/bin/php
<?php <?php
define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
define('DISABLE_SESSIONS', true); define('DISABLE_SESSIONS', true);
if (!defined('PHP_EXECUTABLE')) if (!defined('PHP_EXECUTABLE'))
define('PHP_EXECUTABLE', '/usr/bin/php'); define('PHP_EXECUTABLE', '/usr/bin/php');
error_reporting(DEFAULT_ERROR_LEVEL); require_once "functions.php";
require_once "sanity_check.php"; require_once "sanity_check.php";
require_once "config.php"; require_once "config.php";
require_once "db.php"; require_once "db.php";
require_once "db-prefs.php"; require_once "db-prefs.php";
require_once "functions.php";
$op = $argv[1]; $op = $argv[1];

View File

@ -3,9 +3,6 @@
// This is an experimental multiprocess update daemon. // This is an experimental multiprocess update daemon.
// Some configurable variable may be found below. // Some configurable variable may be found below.
// define('DEFAULT_ERROR_LEVEL', E_ALL);
define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
declare(ticks = 1); declare(ticks = 1);
define('DISABLE_SESSIONS', true); define('DISABLE_SESSIONS', true);
@ -38,8 +35,6 @@
require_once "functions.php"; require_once "functions.php";
require_once "lib/magpierss/rss_fetch.inc"; require_once "lib/magpierss/rss_fetch.inc";
error_reporting(DEFAULT_ERROR_LEVEL);
$children = array(); $children = array();
$ctimes = array(); $ctimes = array();