From 3768fee476bacac4128138fbf079f5b80096f3e2 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 6 Apr 2023 13:38:41 +0700 Subject: [PATCH] Added ability to configure sphinx debug (#137) * Added ability to configure sphinx debug * Update CHANGELOG.md --- CHANGELOG.md | 1 + library/config.php | 3 +++ library/includes/functions.php | 19 ++++++++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55aaae64..7a2410f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Added installed extensions check [\#129](https://github.com/torrentpier/torrentpier-lts/pull/129) ([belomaxorka](https://github.com/belomaxorka)) - Make sql log file name configurable [\#130](https://github.com/torrentpier/torrentpier-lts/pull/130) ([belomaxorka](https://github.com/belomaxorka)) - Enhanced https check [\#131](https://github.com/torrentpier/torrentpier-lts/pull/131), [\#132](https://github.com/torrentpier/torrentpier-lts/pull/132) ([belomaxorka](https://github.com/belomaxorka)) +- Added ability to configure sphinx debug [\#137](https://github.com/torrentpier/torrentpier-lts/pull/137) ([belomaxorka](https://github.com/belomaxorka)) - Minor fixes [\#124](https://github.com/torrentpier/torrentpier-lts/pull/124), [\#133](https://github.com/torrentpier/torrentpier-lts/pull/133), [\#135](https://github.com/torrentpier/torrentpier-lts/pull/135), [\#136](https://github.com/torrentpier/torrentpier-lts/pull/136) ([belomaxorka](https://github.com/belomaxorka)) ## [v2.1.5-2023.03](https://github.com/torrentpier/torrentpier-lts/tree/v2.1.5-2023.03) (2023-04-04) diff --git a/library/config.php b/library/config.php index e1732ddd..3f14d81f 100644 --- a/library/config.php +++ b/library/config.php @@ -377,6 +377,9 @@ $bb_cfg['abuse_email'] = "abuse@$domain_name"; $bb_cfg['adv_email'] = "adv@$domain_name"; // Debug +define('SPHINX_LOG_ERRORS', true); // log sphinx errors +define('SPHINX_LOG_NAME', 'sphinx_errors'); // sphinx log filename + define('DBG_LOG', false); // enable forum debug (off on production) define('DBG_TRACKER', false); // enable tracker debug (off on production) define('COOKIE_DBG', 'bb_dbg'); // debug cookie name diff --git a/library/includes/functions.php b/library/includes/functions.php index 3ea4cbfe..6ef0c8a7 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2443,15 +2443,20 @@ function init_sphinx () function log_sphinx_error ($err_type, $err_msg, $query = '') { - $ignore_err_txt = array( - 'negation on top level', - 'Query word length is less than min prefix length', - ); - if (!count($ignore_err_txt) || !preg_match('#'. join('|', $ignore_err_txt) .'#i', $err_msg)) + if (SPHINX_LOG_ERRORS) { - $orig_query = strtr($_REQUEST['nm'], array("\n" => '\n')); - bb_log(date('m-d H:i:s') ." | $err_type | $err_msg | $orig_query | $query". LOG_LF, 'sphinx_error'); + $ignore_err_txt = array( + 'negation on top level', + 'Query word length is less than min prefix length', + ); + if (!count($ignore_err_txt) || !preg_match('#'. join('|', $ignore_err_txt) .'#i', $err_msg)) + { + $orig_query = strtr($_REQUEST['nm'], array("\n" => '\n')); + bb_log(date('m-d H:i:s') ." | $err_type | $err_msg | $orig_query | $query". LOG_LF, SPHINX_LOG_NAME); + } } + + return false; } function get_title_match_topics ($title_match_sql, $forum_ids = array())