From 1841b825862f812f99aed81442602b4dafc54936 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 7 Nov 2017 17:52:15 -0800 Subject: [PATCH] Plugin update detection fix. --- e107_admin/update_routines.php | 6 ++-- e107_handlers/plugin_class.php | 60 ++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index c0c776833..f95ddceac 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -408,9 +408,9 @@ function update_check() } } - e107::getConfig()->set('db_updates', $dbUpdatesPref)->save(false,true,false); } + e107::getConfig()->set('db_updates', $dbUpdatesPref)->save(false,true,false); // Now check plugins - XXX DEPRECATED @@ -426,11 +426,11 @@ function update_check() } } } - + // New in v2.x if(e107::getPlugin()->updateRequired('boolean')) { - $update_needed = TRUE; + $update_needed = TRUE; } diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index b9a7cdb75..e164b55b4 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -132,6 +132,11 @@ class e_plugin public function getId() { + if(empty($this->_plugdir)) + { + e107::getDebug()->log("\$this->_plugdir is empty ".__FILE__." ". __CLASS__ ."::".__METHOD__); + } + if(isset($this->_ids[$this->_plugdir])) { return $this->_ids[$this->_plugdir]; @@ -155,6 +160,11 @@ class e_plugin public function getInstallRequired() { + if(empty($this->_plugdir)) + { + e107::getDebug()->log("\$this->_plugdir is empty ".__FILE__." ". __CLASS__ ."::".__METHOD__); + } + if(isset($this->_data[$this->_plugdir]['@attributes']['installRequired'])) { return ($this->_data[$this->_plugdir]['@attributes']['installRequired'] === 'true') ? true : false; @@ -167,6 +177,10 @@ class e_plugin public function getVersion() { + if(empty($this->_plugdir)) + { + e107::getDebug()->log("\$this->_plugdir is empty ".__FILE__." ". __CLASS__ ."::".__METHOD__); + } if(isset($this->_data[$this->_plugdir]['@attributes']['version'])) { @@ -288,6 +302,11 @@ class e_plugin */ public function isLegacy() { + if(empty($this->_plugdir)) + { + e107::getDebug()->log("\$this->_plugdir is empty ".__FILE__." ". __CLASS__ ."::".__METHOD__); + } + return $this->_data[$this->_plugdir]['legacy']; } @@ -1051,9 +1070,10 @@ class e107plugin $mes = e107::getMessage(); $needed = array(); $log = e107::getAdminLog(); - + if(!$plugVersions = e107::getConfig('core')->get('plug_installed')) { + return FALSE; } @@ -1062,17 +1082,18 @@ class e107plugin $plg = e107::getPlug(); + + foreach($plugVersions as $path=>$version) { + + $data = $plg->load($path)->getMeta(); + if($plg->isLegacy() === true) { continue; } - $data = $plg->load($path)->getMeta(); - - // $data = $xml->loadXMLfile($fullPath, true); - if(!isset($this->core_plugins[$path])) // check non-core plugins for sql file changes. { $dbv->errors = array(); @@ -1093,24 +1114,26 @@ class e107plugin if($ret = $this->execute_function($path, 'upgrade', 'required', array($this, $curVal, $fileVal))) // Check {plugin}_setup.php and run a 'required' method, if true, then update is required. { - if($mode == 'boolean') + $mes->addDebug("Plugin Update(s) Required in ".$path."_seup.php [".$path."]"); + + if($mode === 'boolean') { - $mes->addDebug("Plugin Update(s) Required in ".$path."_seup.php"); + return TRUE; } - + $needed[$path] = $data; } if(version_compare($curVal,$fileVal,"<")) // check pref version against file version. { - - if($mode == 'boolean') + $mes->addDebug("Plugin Update(s) Required - different version [".$path."]"); + + if($mode === 'boolean') { - $mes->addDebug("Plugin Update(s) Required - different version"); - return TRUE; + return TRUE; } - + // $mes->addDebug("Plugin: {$path} requires an update."); // $log->flushMessages(); @@ -1123,9 +1146,18 @@ class e107plugin // Display debug and log to file. foreach($needed as $path=>$tmp) { - $log->addDebug("Plugin: {$path} requires an update."); + $log->addDebug("Plugin: {$path} requires an update."); } + + + + if($mode === 'boolean') + { + return count($needed) ? true : FALSE; + } + + return count($needed) ? $needed : FALSE; }