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
This commit is contained in:
parent
64b7e77a5a
commit
0f0b8e0430
3 changed files with 51 additions and 45 deletions
|
|
@ -152,17 +152,27 @@ INSERT INTO '. PLUGINS_TABLE .' (id,version)
|
|||
|
||||
case 'update':
|
||||
$previous_version = $this->fs_plugins[$plugin_id]['version'];
|
||||
$upgrade_status = $this->extract_plugin_files('upgrade', $options['revision'], $plugin_id);
|
||||
$errors[0] = $this->extract_plugin_files('upgrade', $options['revision'], $plugin_id);
|
||||
|
||||
if ($upgrade_status === 'ok')
|
||||
if ($errors[0] === 'ok')
|
||||
{
|
||||
$this->get_fs_plugin($plugin_id); // refresh plugins list
|
||||
$new_version = $this->fs_plugins[$plugin_id]['version'];
|
||||
|
||||
$plugin_maintain = self::build_maintain_class($plugin_id);
|
||||
$plugin_maintain->update($previous_version, $this->fs_plugins[$plugin_id]['version']);
|
||||
$plugin_maintain->update($previous_version, $new_version, $errors);
|
||||
|
||||
if ($new_version != 'auto')
|
||||
{
|
||||
$query = '
|
||||
UPDATE '. PLUGINS_TABLE .'
|
||||
SET version=\''. $new_version .'\'
|
||||
WHERE id=\''. $plugin_id .'\'
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
|
||||
return $upgrade_status;
|
||||
break;
|
||||
|
||||
case 'activate':
|
||||
|
|
@ -186,8 +196,7 @@ INSERT INTO '. PLUGINS_TABLE .' (id,version)
|
|||
{
|
||||
$query = '
|
||||
UPDATE '. PLUGINS_TABLE .'
|
||||
SET state=\'active\',
|
||||
version=\''. $this->fs_plugins[$plugin_id]['version'] .'\'
|
||||
SET state=\'active\'
|
||||
WHERE id=\''. $plugin_id .'\'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
|
|
|||
|
|
@ -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 "/*"
|
||||
$fs_version = $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/Version:\\s*([\\w.-]+)/', $line, $matches))
|
||||
{
|
||||
$fs_version = $matches[1];
|
||||
}
|
||||
fclose($fh);
|
||||
|
||||
// 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;
|
||||
|
||||
$maintain_file = PHPWG_PLUGINS_PATH.$plugin['id'].'/maintain.class.php';
|
||||
|
||||
// autoupdate is applicable only to plugins with 2.7 architecture
|
||||
if (file_exists($maintain_file))
|
||||
{
|
||||
global $page;
|
||||
|
||||
// call update method
|
||||
include_once($maintain_file);
|
||||
|
||||
$classname = $plugin['id'].'_maintain';
|
||||
$plugin_maintain = new $classname($plugin['id']);
|
||||
$plugin_maintain->update($plugin['version'], $fs_version, $page['errors']);
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
|
||||
if ($fs_version != null)
|
||||
// update database (only on production)
|
||||
if ($plugin['version'] != 'auto')
|
||||
{
|
||||
global $pwg_loaded_plugins, $page;
|
||||
|
||||
// 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);
|
||||
|
||||
$classname = $plugin['id'].'_maintain';
|
||||
$plugin_maintain = new $classname($plugin['id']);
|
||||
$plugin_maintain->update($plugin['version'], $fs_version, $page['errors']);
|
||||
|
||||
$plugin['version'] = $fs_version;
|
||||
|
||||
// update database (only on production)
|
||||
if ($plugin['version'] != 'auto')
|
||||
{
|
||||
$query = '
|
||||
$query = '
|
||||
UPDATE '. PLUGINS_TABLE .'
|
||||
SET version = "'. $plugin['version'] .'"
|
||||
WHERE id = "'. $plugin['id'] .'"
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ function ws_extensions_update($params, $service)
|
|||
);
|
||||
}
|
||||
|
||||
$upgrade_status = $extension->perform_action('update', $extension_id, array('revision'=>$revision));
|
||||
list($upgrade_status) = $extension->perform_action('update', $extension_id, array('revision'=>$revision));
|
||||
$extension_name = $extension->fs_plugins[$extension_id]['name'];
|
||||
|
||||
if (isset($params['reactivate']))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue