Skip to content

Commit 7e6dbef

Browse files
committed
Prevent core pref corruption by old plugins that are using save_prefs();
1 parent 7ff00ce commit 7e6dbef

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

class2.php

+21
Original file line numberDiff line numberDiff line change
@@ -1717,10 +1717,31 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '')
17171717
e107::getMessage()->addDebug('Deprecated save_prefs() backtrace:<pre>'."\n".print_r($backtrace, true).'</pre>');
17181718
}
17191719

1720+
1721+
1722+
17201723
switch($table)
17211724
{
17221725
case 'core':
17231726
//brute load, force update
1727+
1728+
if(count($pref) < 100) // precaution for old plugins
1729+
{
1730+
$backtrace = debug_backtrace(false);
1731+
1732+
e107::getAdminLog()->add(
1733+
'Core pref corruption avoided',
1734+
"Call to deprecated function save_prefs() (class2.php) with too few prefs. Backtrace:\n".print_r($backtrace, true),
1735+
E_LOG_INFORMATIVE,
1736+
'DEPRECATED'
1737+
);
1738+
1739+
1740+
e107::getMessage()->addDebug('Core-pref corruption avoided. Too few prefs sent to save_prefs(). Backtrace:<pre>'."\n".print_r($backtrace, true).'</pre>');
1741+
return false;
1742+
}
1743+
1744+
17241745
return e107::getConfig()->loadData($pref, false)->save(false, true);
17251746
break;
17261747

e107_handlers/menu_class.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ public function renderArea($parm = '')
451451
public function renderMenu($mpath, $mname='', $parm = '', $return = false)
452452
{
453453
// global $sql; // required at the moment.
454+
455+
454456
global $sc_style, $e107_debug;
455457

456458

@@ -540,7 +542,8 @@ public function renderMenu($mpath, $mname='', $parm = '', $return = false)
540542
$id = e107::getForm()->name2id($mpath . $mname);
541543
$ns->setUniqueId($id);
542544

543-
global $pref; // possibly used by plugin menu.
545+
546+
$pref = e107::getPref(); // possibly used by plugin menu.
544547

545548

546549
$e107_debug ? include(e_PLUGIN.$mpath.$mname.'.php') : @include(e_PLUGIN.$mpath.$mname.'.php');

0 commit comments

Comments
 (0)