aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/upgrades
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-02 23:00:23 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-02 23:00:23 +0000
commitfc21edb0785f2cac11dc592278fad97fffeeb082 (patch)
tree24047873840c5931766abaa5b15a73c0692e7565 /engine/lib/upgrades
parenta826bea54e8934c19b2ada619d966cc7d9628b42 (diff)
downloadelgg-fc21edb0785f2cac11dc592278fad97fffeeb082.tar.gz
elgg-fc21edb0785f2cac11dc592278fad97fffeeb082.tar.bz2
Fixes #1986, #2170, #2225, #2759. Integrated ElggPluginPackage and ElggPluginManifest with ElggPlugin. System now uses ElggPlugin objects to determin plugins. Order is stored in private settings. This absolutely requires running upgrade.php.
git-svn-id: http://code.elgg.org/elgg/trunk@7817 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/upgrades')
-rw-r--r--engine/lib/upgrades/2011010101.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/engine/lib/upgrades/2011010101.php b/engine/lib/upgrades/2011010101.php
new file mode 100644
index 000000000..eac5810c4
--- /dev/null
+++ b/engine/lib/upgrades/2011010101.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Migrate plugins to the new system using ElggPlugin and private settings
+ */
+
+$old_ia = elgg_set_ignore_access(true);
+
+$site = get_config('site');
+$old_plugin_order = unserialize($site->pluginorder);
+$old_enabled_plugins = $site->enabled_plugins;
+
+$db_prefix = get_config('dbprefix');
+$plugin_subtype_id = get_subtype_id('object', 'plugin');
+
+// easy one first: make sure the the site owns all plugin entities.
+$q = "UPDATE {$db_prefix}entities e
+ SET owner_guid = $site->guid, container_guid = $site->guid
+ WHERE e.type = 'object' AND e.subtype = $plugin_subtype_id";
+
+$r = update_data($q);
+
+// rewrite all plugin:setting:* to ELGG_PLUGIN_USER_SETTING_PREFIX . *
+$q = "UPDATE {$db_prefix}private_settings
+ SET name = replace(name, 'plugin:setting', '" . ELGG_PLUGIN_USER_SETTING_PREFIX . "')
+ WHERE name LIKE 'plugin:setting:%'";
+
+$r = update_data($q);
+
+// grab current plugin GUIDs to add a temp priority
+$q = "SELECT * FROM {$db_prefix}entities e
+ JOIN {$db_prefix}objects_entity oe ON e.guid = oe.guid
+ WHERE e.type = 'object' AND e.subtype = $plugin_subtype_id";
+
+$plugins = get_data($q);
+
+foreach ($plugins as $plugin) {
+ $priority = elgg_namespace_plugin_private_setting('internal', 'priority');
+ set_private_setting($plugin->guid, $priority, 0);
+}
+
+// force regenerating plugin entities
+elgg_generate_plugin_entities();
+
+// set the priorities for all plugins
+// this function rewrites it to a normal index so use the current one.
+elgg_set_plugin_priorities($old_plugin_order);
+
+// add relationships for enabled plugins
+if ($old_enabled_plugins) {
+ // they might only have one plugin enabled.
+ if (!is_array($old_enabled_plugins)) {
+ $old_enabled_plugins = array($old_enabled_plugins);
+ }
+
+ // sometimes there were problems and you'd get 1000s of enabled plugins.
+ $old_enabled_plugins = array_unique($old_enabled_plugins);
+
+ foreach ($old_enabled_plugins as $plugin_id) {
+ $plugin = elgg_get_plugin_from_id($plugin_id);
+
+ if ($plugin) {
+ $plugin->activate();
+ }
+ }
+}
+
+// invalidate caches
+elgg_invalidate_simplecache();
+elgg_filepath_cache_reset();
+
+// clean up.
+remove_metadata($site->guid, 'pluginorder');
+remove_metadata($site->guid, 'enabled_plugins');
+
+elgg_set_ignore_access($old_id); \ No newline at end of file