From 5e809047ad7427386e1507a52b7d050379013877 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Mon, 20 Jan 2020 10:01:23 +0800 Subject: [PATCH] By default, no longer treat deprecations as errors Close #363. See also https://www.youtube.com/watch?v=9crnlHLVdno --- inc/config.php | 3 +++ inc/functions.php | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index d1919307..6c53ce3e 100644 --- a/inc/config.php +++ b/inc/config.php @@ -45,6 +45,9 @@ $config['debug'] = false; // For development purposes. Displays (and "dies" on) all errors and warnings. Turn on with the above. $config['verbose_errors'] = true; + // Warn about deprecations? See vichan-devel/vichan#363 and https://www.youtube.com/watch?v=9crnlHLVdno + $config['deprecation_errors'] = false; + // EXPLAIN all SQL queries (when in debug mode). $config['debug_explain'] = false; diff --git a/inc/functions.php b/inc/functions.php index ee056dfa..68ac46e0 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -4,6 +4,7 @@ * Copyright (c) 2010-2014 Tinyboard Development Group */ + if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { // You cannot request this file directly. exit; @@ -279,7 +280,7 @@ function loadConfig() { if ($config['verbose_errors']) { set_error_handler('verbose_error_handler'); - error_reporting(E_ALL); + error_reporting($config['deprecation_errors'] ? E_ALL : E_ALL & ~E_DEPRECATED); ini_set('display_errors', true); ini_set('html_errors', false); } else { @@ -377,8 +378,13 @@ function _syslog($priority, $message) { } function verbose_error_handler($errno, $errstr, $errfile, $errline) { + global $config; + if (error_reporting() == 0) return false; // Looks like this warning was suppressed by the @ operator. + if ($errno == E_DEPRECATED && !$config['deprecation_errors']) + return false; + error(utf8tohtml($errstr), true, array( 'file' => $errfile . ':' . $errline, 'errno' => $errno,