[geeklog-cvs] geeklog: First attempt to get the plugin upgrade working
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Jan 5 05:06:16 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/7fd9bfe6d53f
changeset: 6594:7fd9bfe6d53f
user: Dirk Haun <dirk at haun-online.de>
date: Fri Dec 26 15:58:22 2008 +0100
description:
First attempt to get the plugin upgrade working
diffstat:
3 files changed, 65 insertions(+), 1 deletion(-)
plugins/calendar/functions.inc | 9 +++++++++
public_html/admin/install/index.php | 29 ++++++++++++++++++++++++++++-
public_html/admin/install/lib-install.php | 28 ++++++++++++++++++++++++++++
diffs (110 lines):
diff -r c4c31b02807d -r 7fd9bfe6d53f plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc Fri Dec 26 12:21:20 2008 +0100
+++ b/plugins/calendar/functions.inc Fri Dec 26 15:58:22 2008 +0100
@@ -1432,6 +1432,15 @@
*/
function plugin_upgrade_calendar()
{
+ global $_TABLES, $_CA_CONF;
+
+ $version = DB_getItem($_TABLES['plugins'], 'pi_version',
+ "pi_name = 'calendar'");
+ if ($version == $_CA_CONF['version']) {
+ // nothing to do
+ return true;
+ }
+
// the plugin needs these function so complain when they don't exist
if (!function_exists('PLG_uninstall') ||
!function_exists('COM_createLink')) {
diff -r c4c31b02807d -r 7fd9bfe6d53f public_html/admin/install/index.php
--- a/public_html/admin/install/index.php Fri Dec 26 12:21:20 2008 +0100
+++ b/public_html/admin/install/index.php Fri Dec 26 15:58:22 2008 +0100
@@ -551,9 +551,17 @@
$config->set_default('default_photo', urldecode($site_url) . '/default.jpg');
}
+ // disable plugins for which we don't have the source files
INST_checkPlugins();
- // Installation is complete. Continue onto either plugin installation or success page
+ if (! $install_plugins) {
+ // extra step 4: upgrade plugins
+ $next_link = 'index.php?step=4&mode=' . $install_type
+ . '&language=' . $language;
+ }
+
+ // Installation is complete. Continue onto either plugin
+ // installation or success page
header('Location: ' . $next_link);
} else {
@@ -562,6 +570,19 @@
}
break;
}
+ break;
+
+ /**
+ * Extra Step 4 - Upgrade plugins
+ */
+ case 4:
+ INST_pluginUpgrades();
+
+ $next_link = 'success.php?type=' . $install_type
+ . '&language=' . $language;
+
+ header('Location: ' . $next_link);
+
break;
}
}
@@ -1883,6 +1904,12 @@
case 'install': // Deliberate fall-through, no "break"
case 'upgrade':
+ if (($mode == 'upgrade') && ($step == 4)) {
+ // for the plugin upgrade,
+ // we need lib-common.php in the global(!) namespace
+ require_once '../../lib-common.php';
+ }
+
// Run the installation function
INST_installEngine($mode, $step);
break;
diff -r c4c31b02807d -r 7fd9bfe6d53f public_html/admin/install/lib-install.php
--- a/public_html/admin/install/lib-install.php Fri Dec 26 12:21:20 2008 +0100
+++ b/public_html/admin/install/lib-install.php Fri Dec 26 15:58:22 2008 +0100
@@ -1023,4 +1023,32 @@
return true;
}
+/**
+* Upgrade any enabled plugins
+*
+* @note Needs a fully working Geeklog, so can only be done late in the upgrade
+* process!
+*
+*/
+function INST_pluginUpgrades()
+{
+ global $_CONF, $_TABLES;
+
+ $result = DB_query("SELECT pi_name, pi_version FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
+ $numPlugins = DB_numRows($result);
+
+ for ($i = 0; $i < $numPlugins; $i++) {
+ list($pi_name, $pi_version) = DB_fetchArray($result);
+
+ $code_version = PLG_chkVersion($pi_name);
+ if (! empty($code_version) && ($code_version != $pi_version)) {
+ if (PLG_upgrade($pi_name) !== true) {
+ // upgrade failed - disable plugin
+ DB_query("UPDATE {$_TABLES['plugins']} SET pi_enabled = 0 WHERE pi_name = '$pi_name'");
+ COM_errorLog("Upgrade for '$pi_name' plugin failed - plugin disabled");
+ }
+ }
+ }
+}
+
?>
More information about the geeklog-cvs
mailing list