From ab75f150f8910ea30180b8f8b75291cec1ec33cc Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 20 Jan 2021 12:07:29 -0800 Subject: [PATCH] PHP8 Fixes. Renamed 'search' class (in search.php) to 'search_front' to avoid conflicts. --- e107_core/shortcodes/single/search.php | 12 +++++----- e107_handlers/admin_ui.php | 31 +++++++++++++++----------- e107_handlers/shortcode_handler.php | 11 +++++++-- e107_handlers/sitelinks_class.php | 2 +- e107_tests/tests/unit/e107Test.php | 2 +- e107_tests/tests/unit/scriptsTest.php | 2 +- search.php | 4 ++-- 7 files changed, 39 insertions(+), 25 deletions(-) diff --git a/e107_core/shortcodes/single/search.php b/e107_core/shortcodes/single/search.php index b0e87877f..6745e44e1 100644 --- a/e107_core/shortcodes/single/search.php +++ b/e107_core/shortcodes/single/search.php @@ -14,7 +14,7 @@ function search_shortcode($parm=null) $text = ""; - if(!isset($SEARCH_SHORTCODE)) + if(empty($SEARCH_SHORTCODE)) { if(!$SEARCH_SHORTCODE = e107::getCoreTemplate('search','shortcode')) { @@ -22,6 +22,11 @@ function search_shortcode($parm=null) } } + if(empty($SEARCH_SHORTCODE)) + { + trigger_error('$SEARCH_SHORTCODE template was empty', E_USER_NOTICE); + return null; + } $ref = array(); @@ -60,10 +65,7 @@ function search_shortcode($parm=null) $page = 'all'; } - if(empty($SEARCH_SHORTCODE)) - { - return null; - } + $sc = e107::getScBatch('search'); $sc->wrapper('search/shortcode'); diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index cb24a674f..76ed78e28 100755 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -2202,20 +2202,22 @@ class e_admin_controller $triggerEnabled = $this->triggersEnabled(); if(!e_AJAX_REQUEST && $triggerEnabled) { - $posted = $request->getPosted(); - foreach ($posted as $key => $value) + if($posted = $request->getPosted()) { - if(strpos($key, 'etrigger_') === 0) + foreach ($posted as $key => $value) { - $actionTriggerName = $this->toMethodName($action.$request->camelize(substr($key, 9)), 'trigger', false); - if(method_exists($this, $actionTriggerName)) + if(strpos($key, 'etrigger_') === 0) { - $this->$actionTriggerName($value); - } - //Check if triggers are still enabled - if(!$triggerEnabled) - { - break; + $actionTriggerName = $this->toMethodName($action.$request->camelize(substr($key, 9)), 'trigger', false); + if(method_exists($this, $actionTriggerName)) + { + $this->$actionTriggerName($value); + } + //Check if triggers are still enabled + if(!$triggerEnabled) + { + break; + } } } } @@ -3878,6 +3880,7 @@ class e_admin_controller_ui extends e_admin_controller case 'datestamp': + $opt = array(); if(!is_numeric($value)) { if(!empty($attributes['writeParms'])) @@ -3893,7 +3896,7 @@ class e_admin_controller_ui extends e_admin_controller } - $format = $opt['type'] ? ('input'.$opt['type']) : 'inputdate'; + $format = !empty($opt['type']) ? ('input'.$opt['type']) : 'inputdate'; $value = trim($value) ? e107::getDate()->toTime($value, $format) : 0; } break; @@ -5583,6 +5586,8 @@ class e_admin_ui extends e_admin_controller_ui $data = $this->featurebox; $scount = 0; + $category = 0; + foreach($selected as $id) { if(!$tree->hasNode($id)) @@ -5639,7 +5644,7 @@ class e_admin_ui extends e_admin_controller_ui if($scount > 0) { e107::getMessage()->addSuccess(LAN_CREATED. ' (' .$scount. ') ' .LAN_PLUGIN_FEATUREBOX_NAME); - e107::getMessage()->addSuccess("'); + e107::getMessage()->addSuccess("'); return $scount; } diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 1f168ee5b..dd7a2e2d0 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -1272,8 +1272,15 @@ class e_parse_shortcode if (class_exists($_class, false)) // prevent __autoload - performance { // SecretR - fix array(parm, sc_mode) causing parm to become an array, see issue 424 - // $ret = call_user_func(array($_class, $_function), $parm, $sc_mode); - $ret = e107::callMethod($_class, $_function, $parm, $sc_mode); // v2.3.1 + if(!method_exists($_class, $_function)) + { + trigger_error($_function." doesn't exist in ".$_path, E_USER_NOTICE); + } + else + { + $ret = call_user_func(array($_class, $_function), $parm, $sc_mode); + } + } elseif (function_exists($_function)) { diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index 33f6a27ed..21b291bef 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -1370,7 +1370,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } continue; } - if (isset($e107_vars[$act]['divider'])) + if (isset($e107_vars[$act]['divider']) && !empty($tmpl['divider'])) { // $text .= "
  • "; $text .= $tmpl['divider']; diff --git a/e107_tests/tests/unit/e107Test.php b/e107_tests/tests/unit/e107Test.php index e7bb7d6e8..7934aa54a 100644 --- a/e107_tests/tests/unit/e107Test.php +++ b/e107_tests/tests/unit/e107Test.php @@ -1025,7 +1025,7 @@ class e107Test extends \Codeception\Test\Unit $all = e107::getAddonConfig('e_url'); foreach($all as $plugin => $var) { - if($plugin === 'gallery') // fixme - sef may be enabled or disabled each time tests are run + if($plugin === 'gallery' || $plugin === 'rss_menu') // fixme - sef may be enabled or disabled each time tests are run { continue; } diff --git a/e107_tests/tests/unit/scriptsTest.php b/e107_tests/tests/unit/scriptsTest.php index fd0858b45..f1b835c86 100644 --- a/e107_tests/tests/unit/scriptsTest.php +++ b/e107_tests/tests/unit/scriptsTest.php @@ -123,7 +123,7 @@ continue; } - echo " --- ".$file." --- \n"; + // echo " --- ".$file." --- \n"; ob_start(); // test for PHP Notice/Warning etc. $error = false; diff --git a/search.php b/search.php index cf00785f7..a2902128a 100644 --- a/search.php +++ b/search.php @@ -43,7 +43,7 @@ if (isset($_GET['t']) && is_numeric($_GET['t'])) } -class search extends e_shortcode +class search_front extends e_shortcode { private $search_prefs = array(); @@ -1006,7 +1006,7 @@ class search extends e_shortcode } -$srchObj = new search; +$srchObj = new search_front; $search_info = $srchObj->getConfig(); $search_prefs = $srchObj->getPrefs();