From a35f7ef17145e86ab0b31254c2c69c4dc69ee0d1 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 27 Jan 2015 13:00:33 -0800 Subject: [PATCH] Upgrade routine now separates non-core plugin sql changes into their own area. --- e107_admin/update_routines.php | 4 ++++ e107_handlers/db_verify_class.php | 13 ++++++++++-- e107_handlers/plugin_class.php | 33 +++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index b8392bc12..1848acd80 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -216,6 +216,9 @@ class e107Update function updatePlugin($path) { e107::getPlugin()->install_plugin_xml($path, 'upgrade'); + e107::getMessage()->reset(E_MESSAGE_INFO); + e107::getMessage()->addSuccess(LAN_UPDATED." : ".$path); + } @@ -1136,6 +1139,7 @@ function update_706_to_800($type='') if($plugUpgradeReq = e107::getPlugin()->updateRequired()) { $exclude = array_keys($plugUpgradeReq); // search xxxxx_setup.php and check for 'upgrade_required()' == true. + asort($exclude); } else { diff --git a/e107_handlers/db_verify_class.php b/e107_handlers/db_verify_class.php index 71c4ed4ac..fc6106e12 100644 --- a/e107_handlers/db_verify_class.php +++ b/e107_handlers/db_verify_class.php @@ -90,7 +90,7 @@ class db_verify */ function verify() { - + print_a($_POST); if(vartrue($_POST['verify_table'])) { $this->runComparison($_POST['verify_table']); @@ -112,7 +112,7 @@ class db_verify function runComparison($fileArray) { - + $ns = e107::getRender(); $mes = e107::getMessage(); $frm = e107::getForm(); @@ -366,6 +366,15 @@ class db_verify } } + + /** + * Returns the number of errors + */ + public function errors() + { + return count($this->errors); + } + function renderResults() diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 3d468f1b0..48a663eb0 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -217,13 +217,29 @@ class e107plugin { return FALSE; } + + require_once(e_HANDLER."db_verify_class.php"); + $dbv = new db_verify; + foreach($plugVersions as $path=>$version) { $fullPath = e_PLUGIN.$path."/plugin.xml"; if(is_file(e_PLUGIN.$path."/plugin.xml")) - { + { $data = $xml->loadXMLfile($fullPath, true); + + if(!in_array($path, $this->core_plugins)) // check non-core plugins for sql file changes. + { + $dbv->errors = array(); + $dbv->compare($path); + + if($dbv->errors()) + { + $needed[$path] = $data; + } + } + $curVal = floatval($version); $fileVal = floatval($data['@attributes']['version']); @@ -1347,8 +1363,12 @@ class e107plugin $error = array(); // Array of error messages $canContinue = TRUE; // Clear flag if must abort part way through - - if(is_array($id)) + if(is_string($id)) // Plugin Path. + { + $id = $this->getId($id); + $plug = $this->getinfo($id); // Get plugin info from DB + } + elseif(is_array($id)) { $plug = $id; $id = $plug['plugin_id']; @@ -1358,7 +1378,7 @@ class e107plugin $id = (int) $id; $plug = $this->getinfo($id); // Get plugin info from DB } - + $this->current_plug = $plug; $txt = ''; @@ -1407,6 +1427,7 @@ class e107plugin if (!$canContinue) { + return FALSE; } @@ -1447,6 +1468,7 @@ class e107plugin $mes->add($txt, $status); break; case 'upgrade': + $tmp = $dbHandler->update_table_structure($ct, FALSE, TRUE, $pref['multilanguage']); if ($tmp === FALSE) { @@ -1456,6 +1478,9 @@ class e107plugin { $error[] = $tmp; } + + + break; case 'refresh': // Leave things alone break;