From 6bdf4a1a25f1fc2e84fdc65e3e6a74578536f137 Mon Sep 17 00:00:00 2001 From: wn Date: Sat, 12 Dec 2020 09:50:43 -0600 Subject: [PATCH] Switch to 'get_error_types()' to ensure availability in 'include/functions.php'. The global in 'sanity_check()' was null... possibly due to circular requires? --- errors.php | 42 ++++++++++++++++++++++-------------------- include/functions.php | 4 ++-- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/errors.php b/errors.php index deadb1e24..68164974b 100644 --- a/errors.php +++ b/errors.php @@ -4,48 +4,50 @@ require_once "functions.php"; - $ERRORS[0] = ""; + function get_error_types() { + $ERRORS[0] = ""; - $ERRORS[1] = __("This program requires XmlHttpRequest " . - "to function properly. Your browser doesn't seem to support it."); + $ERRORS[1] = __("This program requires XmlHttpRequest " . + "to function properly. Your browser doesn't seem to support it."); - $ERRORS[2] = __("This program requires cookies " . - "to function properly. Your browser doesn't seem to support them."); + $ERRORS[2] = __("This program requires cookies " . + "to function properly. Your browser doesn't seem to support them."); - $ERRORS[3] = __("Backend sanity check failed."); + $ERRORS[3] = __("Backend sanity check failed."); - $ERRORS[4] = __("Frontend sanity check failed."); + $ERRORS[4] = __("Frontend sanity check failed."); - $ERRORS[5] = __("Incorrect database schema version. <a href='db-updater.php'>Please update</a>."); + $ERRORS[5] = __("Incorrect database schema version. <a href='db-updater.php'>Please update</a>."); - $ERRORS[6] = __("Request not authorized."); + $ERRORS[6] = __("Request not authorized."); - $ERRORS[7] = __("No operation to perform."); + $ERRORS[7] = __("No operation to perform."); - $ERRORS[8] = __("Could not display feed: query failed. Please check label match syntax or local configuration."); + $ERRORS[8] = __("Could not display feed: query failed. Please check label match syntax or local configuration."); - $ERRORS[8] = __("Denied. Your access level is insufficient to access this page."); + $ERRORS[8] = __("Denied. Your access level is insufficient to access this page."); - $ERRORS[9] = __("Configuration check failed"); + $ERRORS[9] = __("Configuration check failed"); - $ERRORS[10] = __("Your version of MySQL is not currently supported. Please see official site for more information."); + $ERRORS[10] = __("Your version of MySQL is not currently supported. Please see official site for more information."); - $ERRORS[11] = "[This error is not returned by server]"; + $ERRORS[11] = "[This error is not returned by server]"; - $ERRORS[12] = __("SQL escaping test failed, check your database and PHP configuration"); + $ERRORS[12] = __("SQL escaping test failed, check your database and PHP configuration"); - $ERRORS[13] = __("Method not found"); + $ERRORS[13] = __("Method not found"); - $ERRORS[14] = __("Plugin not found"); + $ERRORS[14] = __("Plugin not found"); - $ERRORS[15] = __("Encoding data as JSON failed"); + $ERRORS[15] = __("Encoding data as JSON failed"); + } if ($_REQUEST['mode'] == 'js') { header("Content-Type: text/javascript; charset=UTF-8"); print "var ERRORS = [];\n"; - foreach ($ERRORS as $id => $error) { + foreach (get_error_types() as $id => $error) { $error = preg_replace("/\n/", "", $error); $error = preg_replace("/\"/", "\\\"", $error); diff --git a/include/functions.php b/include/functions.php index ceb7fbd9e..2f4ee8e35 100644 --- a/include/functions.php +++ b/include/functions.php @@ -327,7 +327,7 @@ function sanity_check() { require_once 'errors.php'; - global $ERRORS; + $ERRORS = get_error_types(); $error_code = 0; $schema_version = get_schema_version(true); @@ -540,7 +540,7 @@ */ function error_json($code) { require_once "errors.php"; - global $ERRORS; + $ERRORS = get_error_types(); @$message = $ERRORS[$code];