Commit 65b25ff8 authored by Penny Leach's avatar Penny Leach
Browse files

versions and releases for plugins should be stored in

installed_$plugintype instead of config_$plugintype. lots of changes to
support this. new plugin_types function too
parent 13ed1d43
......@@ -7,8 +7,9 @@
<TABLE NAME="installed_artefact" COMMENT="Information about each installed artefact plugin" NEXT="installed_auth">
<FIELDS>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" NEXT="version" />
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="active"/>
<FIELD NAME="active" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="version"/>
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="release"/>
<FIELD NAME="release" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="version" NEXT="active"/>
<FIELD NAME="active" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="release"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="name" COMMENT="Primary key for installed artefact plugins" />
......@@ -17,8 +18,9 @@
<TABLE NAME="installed_auth" COMMENT="Information about each installed authentication plugin" PREVIOUS="installed_artefact" NEXT="config">
<FIELDS>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" NEXT="version" />
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="active"/>
<FIELD NAME="active" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="version"/>
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="release"/>
<FIELD NAME="release" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="version" NEXT="active"/>
<FIELD NAME="active" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="release"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="name" COMMENT="Primary key for installed authentication plugins" />
......
......@@ -75,6 +75,19 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($status && $oldversion < 2006102000) {
// add release field to installed_artefact and installed_auth
$artefact_t = new XMLDBTable('installed_artefact');
$auth_t = new XMLDBTable('installed_auth');
$field = new XMLDBField('release');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL);
$status = $status && add_field($artefact_t, $field);
$status = $status && add_field($auth_t, $field);
}
return $status;
}
......
......@@ -33,8 +33,8 @@ defined('INTERNAL') || die();
* @returns array of objects
*/
function check_upgrades($name = null) {
// An array of plugins to check
static $pluginstocheck = array('artefact', 'auth');
$pluginstocheck = plugin_types();
$toupgrade = array();
$installing = false;
......@@ -74,9 +74,6 @@ function check_upgrades($name = null) {
}
$plugins = array();
//if (strpos($name, 'artefact.') === 0) {
// $plugins[] = substr($name, 9);
//}
if (!empty($name)) {
$plugins[] = explode('.', $name);
}
......@@ -104,15 +101,17 @@ function check_upgrades($name = null) {
$pluginpath = "$plugin[0]/$plugin[1]";
$pluginkey = "$plugin[0].$plugin[1]";
require(get_config('docroot') . $pluginpath . '/version.php');
$pluginversion = 0;
// Don't try to get a plugin version if we are installing - it will
// Don't try to get the plugin info if we are installing - it will
// definitely fail
$pluginversion = 0;
if (!$installing) {
try {
$pluginversion = get_config_plugin($plugintype, $pluginname, 'version');
if ($installed = get_record('installed_' . $plugintype, 'name', $pluginname)) {
$pluginversion = $installed->version;
$pluginrelease = $installed->release;
}
catch (Exception $e) { }
require(get_config('docroot') . $pluginpath . '/version.php');
}
if (empty($pluginversion)) {
......@@ -126,10 +125,7 @@ function check_upgrades($name = null) {
$plugininfo = new StdClass;
$plugininfo->upgrade = true;
$plugininfo->from = $pluginversion;
try {
$plugininfo->fromrelease = get_config_plugin('artefact', $dir, 'release');
}
catch (Exception $e) { }
$plugininfo->fromrelease = $pluginrelease;
$plugininfo->to = $config->version;
$plugininfo->torelease = $config->release;
$toupgrade[$pluginkey] = $plugininfo;
......@@ -213,8 +209,18 @@ function upgrade_plugin($upgrade) {
throw new DatalibException("Failed to upgrade $upgrade->name");
}
$status = set_config_plugin($plugintype, $pluginname, 'version', $upgrade->to);
$status = $status && set_config_plugin($plugintype, $pluginname, 'release', $upgrade->torelease);
$installed = new StdClass;
$installed->name = $pluginname;
$installed->version = $upgrade->to;
$installed->release = $upgrade->torelease;
$installtable = 'installed_' . $plugintype;
if (!empty($upgrade->install)) {
insert_record($installtable,$installed);
}
else {
update_record($installtable, $installed, 'name');
}
// @todo here is where plugins register events and set their crons up
......@@ -709,6 +715,19 @@ function safe_require($plugintype, $pluginname, $filename, $function='require',
}
/**
* This function returns the list of plugintypes we currently care about
* @return array of names
*/
function plugin_types() {
static $pluginstocheck;
if (empty($pluginstocheck)) {
$pluginstocheck = array('artefact', 'auth');
}
return $pluginstocheck;
}
/**
* Used by XMLDB
*/
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2006101900;
$config->version = 2006102000;
$config->release = '0.1';
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment