1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +02:00

Fixed E_NOTICE in plugin install/uninstall process

- FIX: e107::coreLan() now loads the lan_admin.php file if the $admin argument is true
- FIX: Variable scope of $eplug_folder in e107plugin::uninstall()
- FIX: isset() check order in pluginsTest::makePluginReport()
- FIX: class2.php: Missing ADMINPERMS constant in CLI mode
This commit is contained in:
Nick Liu
2020-01-17 17:11:26 +01:00
parent bfad3f7202
commit 62a547aed2
4 changed files with 132 additions and 134 deletions

View File

@@ -1417,12 +1417,6 @@ define('TIMEOFFSET', $e_deltaTime);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
$sql->db_Mark_Time('Find/Load Theme'); $sql->db_Mark_Time('Find/Load Theme');
if(e_ADMIN_AREA) // Load admin phrases ASAP
{
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php');
}
if(!defined('THEME')) if(!defined('THEME'))
{ {
@@ -2032,6 +2026,7 @@ e107::getDebug()->log("Timezone: ".USERTIMEZONE); // remove later on.
define('USERNAME', 'e107-cli'); define('USERNAME', 'e107-cli');
define('USERTHEME', false); define('USERTHEME', false);
define('ADMIN', true); define('ADMIN', true);
define('ADMINPERMS', false);
define('GUEST', false); define('GUEST', false);
define('USERCLASS', ''); define('USERCLASS', '');
define('USEREMAIL', ''); define('USEREMAIL', '');

View File

@@ -3145,6 +3145,11 @@ class e107
*/ */
public static function coreLan($fname, $admin = false) public static function coreLan($fname, $admin = false)
{ {
if ($admin)
{
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php');
}
$cstring = 'corelan/'.e_LANGUAGE.'_'.$fname.($admin ? '_admin' : '_front'); $cstring = 'corelan/'.e_LANGUAGE.'_'.$fname.($admin ? '_admin' : '_front');
if(self::getRegistry($cstring)) return; if(self::getRegistry($cstring)) return;

View File

@@ -4311,7 +4311,6 @@ class e107plugin
} }
public function uninstall($id, $options = array()) public function uninstall($id, $options = array())
{ {
$pref = e107::getPref(); $pref = e107::getPref();
@@ -4322,12 +4321,12 @@ class e107plugin
$sql = e107::getDb(); $sql = e107::getDb();
$plug = e107plugin::getPluginRecord($id); $plug = e107plugin::getPluginRecord($id);
$this->log("Uninstalling :".$plug['plugin_path']." with options: ".print_r($options, true)); $this->log("Uninstalling :" . $plug['plugin_path'] . " with options: " . print_r($options, true));
$this->log("e107plugin::getPluginRecord() returned: ".print_r($plug, true)); $this->log("e107plugin::getPluginRecord() returned: " . print_r($plug, true));
// Check if plugin is being used by another plugin before uninstalling it. // Check if plugin is being used by another plugin before uninstalling it.
if(isset($plug['plugin_path'])) if (isset($plug['plugin_path']))
{ {
if ($this->isUsedByAnotherPlugin($plug['plugin_path'])) if ($this->isUsedByAnotherPlugin($plug['plugin_path']))
{ {
@@ -4338,14 +4337,14 @@ class e107plugin
$text = ''; $text = '';
//Uninstall Plugin //Uninstall Plugin
if ($plug['plugin_installflag'] == true ) $eplug_folder = $plug['plugin_path'];
if ($plug['plugin_installflag'] == true)
{ {
$this->log("plugin_installflag = true, proceeding to uninstall"); $this->log("plugin_installflag = true, proceeding to uninstall");
$eplug_folder = $plug['plugin_path']; $_path = e_PLUGIN . $plug['plugin_path'] . '/';
$_path = e_PLUGIN.$plug['plugin_path'].'/';
if(file_exists($_path.'plugin.xml')) if (file_exists($_path . 'plugin.xml'))
{ {
unset($_POST['uninstall_confirm']); unset($_POST['uninstall_confirm']);
$this->install_plugin_xml($plug, 'uninstall', $options); //$_POST must be used. $this->install_plugin_xml($plug, 'uninstall', $options); //$_POST must be used.
@@ -4354,8 +4353,8 @@ class e107plugin
{ // Deprecated - plugin uses plugin.php { // Deprecated - plugin uses plugin.php
$eplug_table_names = null; $eplug_table_names = null;
$eplug_prefs = null; $eplug_prefs = null;
$eplug_comment_ids= null; $eplug_comment_ids = null;
$eplug_array_pref= null; $eplug_array_pref = null;
$eplug_menu_name = null; $eplug_menu_name = null;
$eplug_link = null; $eplug_link = null;
$eplug_link_url = null; $eplug_link_url = null;
@@ -4363,15 +4362,15 @@ class e107plugin
$eplug_userclass = null; $eplug_userclass = null;
$eplug_version = null; $eplug_version = null;
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php'); include(e_PLUGIN . $plug['plugin_path'] . '/plugin.php');
$func = $eplug_folder.'_uninstall'; $func = $eplug_folder . '_uninstall';
if (function_exists($func)) if (function_exists($func))
{ {
$text .= call_user_func($func); $text .= call_user_func($func);
} }
if(!empty($options['delete_tables'])) if (!empty($options['delete_tables']))
{ {
if (is_array($eplug_table_names)) if (is_array($eplug_table_names))
@@ -4379,47 +4378,47 @@ class e107plugin
$result = $this->manage_tables('remove', $eplug_table_names); $result = $this->manage_tables('remove', $eplug_table_names);
if ($result !== TRUE) if ($result !== TRUE)
{ {
$text .= EPL_ADLAN_27.' <b>'.MPREFIX.$result.'</b> - '.EPL_ADLAN_30.'<br />'; $text .= EPL_ADLAN_27 . ' <b>' . MPREFIX . $result . '</b> - ' . EPL_ADLAN_30 . '<br />';
$this->log("Unable to delete table."); // No LANS $this->log("Unable to delete table."); // No LANS
} }
else else
{ {
$text .= EPL_ADLAN_28."<br />"; $text .= EPL_ADLAN_28 . "<br />";
$this->log("Deleting tables."); // NO LANS $this->log("Deleting tables."); // NO LANS
} }
} }
} }
else else
{ {
$text .= EPL_ADLAN_49."<br />"; $text .= EPL_ADLAN_49 . "<br />";
$this->log("Tables left intact by request."); // No LANS $this->log("Tables left intact by request."); // No LANS
} }
if (is_array($eplug_prefs)) if (is_array($eplug_prefs))
{ {
$this->manage_prefs('remove', $eplug_prefs); $this->manage_prefs('remove', $eplug_prefs);
$text .= EPL_ADLAN_29."<br />"; $text .= EPL_ADLAN_29 . "<br />";
} }
if (is_array($eplug_comment_ids)) if (is_array($eplug_comment_ids))
{ {
$text .= ($this->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."<br />" : ""; $text .= ($this->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50 . "<br />" : "";
} }
if (is_array($eplug_array_pref)) if (is_array($eplug_array_pref))
{ {
foreach($eplug_array_pref as $key => $val) foreach ($eplug_array_pref as $key => $val)
{ {
$this->manage_plugin_prefs('remove', $key, $eplug_folder, $val); $this->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
} }
} }
/* /*
if ($eplug_menu_name) if ($eplug_menu_name)
{ {
$sql->delete('menus', "menu_name='{$eplug_menu_name}' "); $sql->delete('menus', "menu_name='{$eplug_menu_name}' ");
}*/ }*/
$folderFiles = scandir(e_PLUGIN.$plug['plugin_path']); $folderFiles = scandir(e_PLUGIN . $plug['plugin_path']);
$this->XmlMenus($eplug_folder,'uninstall',$folderFiles); $this->XmlMenus($eplug_folder, 'uninstall', $folderFiles);
if ($eplug_link) if ($eplug_link)
{ {
@@ -4443,10 +4442,10 @@ class e107plugin
} }
e107::getConfig('core')->setPref($pref); e107::getConfig('core')->setPref($pref);
$this->rebuildUrlConfig(); $this->rebuildUrlConfig();
e107::getConfig('core')->save(false,true,false); e107::getConfig('core')->save(false, true, false);
} }
$logInfo = deftrue($plug['plugin_name'],$plug['plugin_name']). " v".$plug['plugin_version']." ({e_PLUGIN}".$plug['plugin_path'].")"; $logInfo = deftrue($plug['plugin_name'], $plug['plugin_name']) . " v" . $plug['plugin_version'] . " ({e_PLUGIN}" . $plug['plugin_path'] . ")";
e107::getLog()->add('PLUGMAN_03', $logInfo, E_LOG_INFORMATIVE, ''); e107::getLog()->add('PLUGMAN_03', $logInfo, E_LOG_INFORMATIVE, '');
} }
else else
@@ -4454,18 +4453,18 @@ class e107plugin
$this->log("plugin_installflag = false, uninstall skipped."); $this->log("plugin_installflag = false, uninstall skipped.");
} }
if(!empty($options['delete_files']) && ($plug['plugin_installflag'] == true)) if (!empty($options['delete_files']) && ($plug['plugin_installflag'] == true))
{ {
if(!empty($eplug_folder)) if (!empty($eplug_folder))
{ {
$result = e107::getFile()->rmtree(e_PLUGIN.$eplug_folder); $result = e107::getFile()->rmtree(e_PLUGIN . $eplug_folder);
e107::getDb()->delete('plugin', "plugin_path='".$eplug_folder."'"); e107::getDb()->delete('plugin', "plugin_path='" . $eplug_folder . "'");
$text .= ($result ? '<br />'.EPL_ADLAN_86.e_PLUGIN.$eplug_folder : '<br />'.EPL_ADLAN_87.'<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32); $text .= ($result ? '<br />' . EPL_ADLAN_86 . e_PLUGIN . $eplug_folder : '<br />' . EPL_ADLAN_87 . '<br />' . EPL_ADLAN_31 . ' <b>' . e_PLUGIN . $eplug_folder . '</b> ' . EPL_ADLAN_32);
} }
} }
else else
{ {
$text .= '<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32; $text .= '<br />' . EPL_ADLAN_31 . ' <b>' . e_PLUGIN . $eplug_folder . '</b> ' . EPL_ADLAN_32;
} }
e107::getPlug()->clearCache()->buildAddonPrefLists(); e107::getPlug()->clearCache()->buildAddonPrefLists();
@@ -4475,7 +4474,6 @@ class e107plugin
$this->log("Uninstall completed"); $this->log("Uninstall completed");
return $text; return $text;
} }

View File

@@ -42,10 +42,10 @@
$debug_text .= "---- Pref: plug_installed (version)\n\n"; $debug_text .= "---- Pref: plug_installed (version)\n\n";
$pref = e107::getConfig('core',true,true)->get('plug_installed'); $pref = e107::getConfig('core',true,true)->get('plug_installed');
$debug_text .= print_r($pref[$pluginDir],true);
$installedPref = isset($pref[$pluginDir]) ? $pref[$pluginDir] : false; $installedPref = isset($pref[$pluginDir]) ? $pref[$pluginDir] : false;
$debug_text .= print_r($installedPref,true);
$debug_text .= "\n\n---- Plugin Prefs: \n\n"; $debug_text .= "\n\n---- Plugin Prefs: \n\n";
$pluginPref = e107::pref($pluginDir); $pluginPref = e107::pref($pluginDir);
$debug_text .= print_r($pluginPref,true); $debug_text .= print_r($pluginPref,true);