From 7e6dbefd1acf18a9efa6838b441e0670719bad36 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 18 Jan 2017 19:56:27 -0800 Subject: [PATCH] Prevent core pref corruption by old plugins that are using save_prefs(); --- class2.php | 21 +++++++++++++++++++++ e107_handlers/menu_class.php | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/class2.php b/class2.php index b2c7248f3..eff84b133 100644 --- a/class2.php +++ b/class2.php @@ -1717,10 +1717,31 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '') e107::getMessage()->addDebug('Deprecated save_prefs() backtrace:
'."\n".print_r($backtrace, true).'
'); } + + + switch($table) { case 'core': //brute load, force update + + if(count($pref) < 100) // precaution for old plugins + { + $backtrace = debug_backtrace(false); + + e107::getAdminLog()->add( + 'Core pref corruption avoided', + "Call to deprecated function save_prefs() (class2.php) with too few prefs. Backtrace:\n".print_r($backtrace, true), + E_LOG_INFORMATIVE, + 'DEPRECATED' + ); + + + e107::getMessage()->addDebug('Core-pref corruption avoided. Too few prefs sent to save_prefs(). Backtrace:
'."\n".print_r($backtrace, true).'
'); + return false; + } + + return e107::getConfig()->loadData($pref, false)->save(false, true); break; diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php index 79feebd60..a74ea5d8e 100644 --- a/e107_handlers/menu_class.php +++ b/e107_handlers/menu_class.php @@ -451,6 +451,8 @@ class e_menu public function renderMenu($mpath, $mname='', $parm = '', $return = false) { // global $sql; // required at the moment. + + global $sc_style, $e107_debug; @@ -540,7 +542,8 @@ class e_menu $id = e107::getForm()->name2id($mpath . $mname); $ns->setUniqueId($id); - global $pref; // possibly used by plugin menu. + + $pref = e107::getPref(); // possibly used by plugin menu. $e107_debug ? include(e_PLUGIN.$mpath.$mname.'.php') : @include(e_PLUGIN.$mpath.$mname.'.php');