From 0f0b8e0430fd4bb6f7df76d2d7a1b54e99b744d3 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Thu, 25 Sep 2014 09:25:24 +0000 Subject: final fix for plugins update ? - plugins.version is not updated in "activate" action - plugins.version is updated in "update" action and "load_plugin()" function (not only for plugins using maintain.class.php) cases covered: - autoupdate while active or inactive - FTP update while active or inactive git-svn-id: http://piwigo.org/svn/trunk@29779 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_plugins.inc.php | 73 +++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 38 deletions(-) (limited to 'include/functions_plugins.inc.php') diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php index 5790eccf7..8700a599f 100644 --- a/include/functions_plugins.inc.php +++ b/include/functions_plugins.inc.php @@ -376,59 +376,56 @@ function load_plugin($plugin) */ function autoupdate_plugin(&$plugin) { - $maintain_file = PHPWG_PLUGINS_PATH.$plugin['id'].'/maintain.class.php'; + // try to find the filesystem version in lines 2 to 10 of main.inc.php + $fh = fopen(PHPWG_PLUGINS_PATH.$plugin['id'].'/main.inc.php', 'r'); + $fs_version = null; + $i = -1; - // autoupdate is applicable only to plugins with 2.7 architecture - if (file_exists($maintain_file)) + while (($line = fgets($fh))!==false && $fs_version==null && $i<10) { - // try to find the filesystem version in lines 2 to 10 of main.inc.php - $fh = fopen(PHPWG_PLUGINS_PATH.$plugin['id'].'/main.inc.php', 'r'); - $fs_version = null; - $i = -1; + $i++; + if ($i < 2) continue; // first lines are typically "update($plugin['version'], $fs_version, $page['errors']); + // autoupdate is applicable only to plugins with 2.7 architecture + if (file_exists($maintain_file)) + { + global $page; - $plugin['version'] = $fs_version; + // call update method + include_once($maintain_file); - // update database (only on production) - if ($plugin['version'] != 'auto') - { - $query = ' + $classname = $plugin['id'].'_maintain'; + $plugin_maintain = new $classname($plugin['id']); + $plugin_maintain->update($plugin['version'], $fs_version, $page['errors']); + } + + // update database (only on production) + if ($plugin['version'] != 'auto') + { + $query = ' UPDATE '. PLUGINS_TABLE .' SET version = "'. $plugin['version'] .'" WHERE id = "'. $plugin['id'] .'" ;'; - pwg_query($query); - } - } + pwg_query($query); } } } -- cgit v1.2.3