aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_plugins.inc.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2014-09-25 19:23:52 +0000
committermistic100 <mistic@piwigo.org>2014-09-25 19:23:52 +0000
commit4f41b2e9ae31d1394122f597a7ff55e189baf0f5 (patch)
treead93e8f36cd1ef944032e24d5349f68403dd28e0 /include/functions_plugins.inc.php
parent5d666f8566e7c8d57591369261921eb7c8894a18 (diff)
Merged revision(s) 29773, 29778-29779 from trunk:
fix plugins autoupdate: call ##_maintain::update when updating from back-office - 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/branches/2.7@29792 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_plugins.inc.php73
1 files changed, 35 insertions, 38 deletions
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 "<?php" and "/*"
- while (($line = fgets($fh))!==false && $fs_version==null && $i<10)
+ if (preg_match('/Version:\\s*([\\w.-]+)/', $line, $matches))
{
- $i++;
- if ($i < 2) continue; // first lines are typically "<?php" and "/*"
-
- if (preg_match('/Version:\\s*([\\w.-]+)/', $line, $matches))
- {
- $fs_version = $matches[1];
- }
+ $fs_version = $matches[1];
}
+ }
- fclose($fh);
+ fclose($fh);
- if ($fs_version != null)
- {
- global $pwg_loaded_plugins, $page;
+ // if version is auto (dev) or superior
+ if ($fs_version != null && (
+ $fs_version == 'auto' || $plugin['version'] == 'auto' ||
+ safe_version_compare($plugin['version'], $fs_version, '<')
+ )
+ ) {
+ $plugin['version'] = $fs_version;
- // if version is auto (dev) or superior
- if (
- $fs_version == 'auto' or $plugin['version'] == 'auto'
- or safe_version_compare($plugin['version'], $fs_version, '<')
- )
- {
- // call update method
- include_once($maintain_file);
+ $maintain_file = PHPWG_PLUGINS_PATH.$plugin['id'].'/maintain.class.php';
- $classname = $plugin['id'].'_maintain';
- $plugin_maintain = new $classname($plugin['id']);
- $plugin_maintain->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);
}
}
}