/** * @expectedException UnexpectedValueException * @expectedExceptionMessage ElggUpgrade objects must have a value for the id property. */ public function testThrowsOnSaveWithoutId() { $this->obj->setClass('test'); $this->obj->description = 'Test'; $this->obj->title = 'Test'; $this->obj->save(); }
public static function convertTimestamps($event, $type, $object) { $ia = elgg_set_ignore_access(true); $path = 'admin/upgrades/convert_timestamps'; $upgrade = new \ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = elgg_echo('admin:upgrades:convert_timestamps'); $upgrade->description = elgg_echo('admin:upgrades:convert_timestamps:description'); $upgrade->save(); } elgg_set_ignore_access($ia); }
/** * Listen to the upgrade event to check if there is any old content with unsent tag notifications * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $entity supplied entity/params * * @return void */ public static function markOldTagsAsSent($event, $type, $entity) { $path = 'admin/upgrades/set_tag_notifications_sent'; $upgrade = new \ElggUpgrade(); // ignore acces while checking for existence $ia = elgg_set_ignore_access(true); // already registered? if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->title = elgg_echo('admin:upgrades:set_tag_notifications_sent'); $upgrade->description = elgg_echo('admin:upgrades:set_tag_notifications_sent:description'); $upgrade->setPath($path); $upgrade->save(); } // restore access elgg_set_ignore_access($ia); }
/** * Register an upgrade class to move the blog icons * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $object supplied object/params * * @return void */ public static function moveBlogIcons($event, $type, $object) { $ia = elgg_set_ignore_access(true); $path = 'admin/upgrades/blog_tools_move_icons'; $upgrade = new \ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = elgg_echo('admin:upgrades:blog_tools_move_icons'); $upgrade->description = elgg_echo('admin:upgrades:blog_tools_move_icons:description'); $upgrade->save(); // check for blog with icons // eg. if non found, no upgrade needed $count = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => 'blog', 'metadata_name' => 'icontime', 'count' => true]); if (empty($count)) { $upgrade->setCompleted(); } } // restore access elgg_set_ignore_access($ia); }
/** * Listen to the upgrade event to make sure upgrades can be run * * @param string $event the name of the event * @param string $type the type of the event * @param null $object nothing * * @return void */ function thewire_tools_upgrade_system_event_handler($event, $type, $object) { // Upgrade also possible hidden entities. This feature get run // by an administrator so there's no need to ignore access. $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); // register an upgrade script $options = array("type" => "user", "plugin_id" => "thewire_tools", "plugin_user_setting_name" => "notify_mention", "count" => true); $count = elgg_get_entities_from_plugin_user_settings($options); if ($count) { $path = "admin/upgrades/thewire_tools_mentions"; $upgrade = new ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = "TheWire Tools mentions upgrade"; $upgrade->description = "The way mention notifications are handled has changed. Run this script to make sure all settings are migrated."; $upgrade->save(); } } access_show_hidden_entities($access_status); }
/** * Listen to the upgrade event * * @param string $event name of the event * @param string $type type of the event * @param null $object supplied object * * @return void */ function content_subscriptions_upgrade_system_handler($event, $type, $object) { // Upgrade also possible hidden entities. This feature get run // by an administrator so there's no need to ignore access. $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); // register an upgrade script $options = array("type" => "user", "relationship" => CONTENT_SUBSCRIPTIONS_SUBSCRIPTION, "inverse_relationship" => true, "count" => true); $count = elgg_get_entities_from_relationship($options); if ($count) { $path = "admin/upgrades/content_subscriptions"; $upgrade = new ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = "Content Subscription upgrade"; $upgrade->description = "The way content subscriptions are handled has changed. Run this script to make sure all content subscriptions are migrated."; $upgrade->save(); } } access_show_hidden_entities($access_status); }
/** * Listen to the upgrade event, to register a script * * @param string $event name of the event * @param string $type type of the event * @param null $object supplied object * * @return void */ public static function registerScript($event, $type, $object) { // Upgrade also possible hidden entities. This feature get run // by an administrator so there's no need to ignore access. $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); // register an upgrade script $options = array('type' => 'user', 'relationship' => CONTENT_SUBSCRIPTIONS_SUBSCRIPTION, 'inverse_relationship' => true, 'count' => true); $count = elgg_get_entities_from_relationship($options); if ($count) { $path = 'admin/upgrades/content_subscriptions'; $upgrade = new \ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = 'Content Subscription upgrade'; $upgrade->description = 'The way content subscriptions are handled has changed. Run this script to make sure all content subscriptions are migrated.'; $upgrade->save(); } } access_show_hidden_entities($access_status); }
/** * Listen to upgrade event * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $object supplied params * * @return void */ public static function migrateSteps($event, $type, $object) { $path = 'admin/upgrades/migrate_wizard_steps'; $upgrade = new \ElggUpgrade(); // ignore acces while checking for existence $ia = elgg_set_ignore_access(true); // already registered? if ($upgrade->getUpgradeFromPath($path)) { // restore access elgg_set_ignore_access($ia); return; } // find if upgrade is needed $upgrade_needed = false; $batch = new \ElggBatch('elgg_get_entities', ['type' => 'object', 'subtype' => \Wizard::SUBTYPE, 'limit' => false]); foreach ($batch as $entity) { $fa = new \ElggFile(); $fa->owner_guid = $entity->getGUID(); $fa->setFilename('steps.json'); if (!$fa->exists()) { continue; } $upgrade_needed = true; break; } if (!$upgrade_needed) { // restore access elgg_set_ignore_access($ia); return; } $upgrade->title = elgg_echo('admin:upgrades:migrate_wizard_steps'); $upgrade->description = elgg_echo('admin:upgrades:migrate_wizard_steps:description'); $upgrade->setPath($path); $upgrade->save(); // restore access elgg_set_ignore_access($ia); }
* Convert comment annotations to entities. * * Register comment subtype and add ElggUpgrade for ajax upgrade. * * We do not migrate comments in this upgrade. See the comment * upgrade action in actions/admin/upgrades/upgrade_comments.php for that. */ // Register subtype and class for comments if (get_subtype_id('object', 'comment')) { update_subtype('object', 'comment', 'ElggComment'); } else { add_subtype('object', 'comment', 'ElggComment'); } $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); $ia = elgg_set_ignore_access(true); // add ElggUpgrade object if need to migrate comments $options = array('annotation_names' => 'generic_comment', 'order_by' => 'n_table.id DESC', 'count' => true); if (elgg_get_annotations($options)) { $url = "admin/upgrades/comments"; $upgrade = new ElggUpgrade(); // Create the upgrade if one with the same URL doesn't already exist if (!$upgrade->getUpgradeFromURL($url)) { $upgrade->setURL($url); $upgrade->title = 'Comments Upgrade'; $upgrade->description = 'Comments have been improved in Elgg 1.9 and require a migration. Run this upgrade to complete the migration.'; $upgrade->save(); } } elgg_set_ignore_access($ia); access_show_hidden_entities($access_status);
/** * @expectedException UnexpectedValueException * @expectedExceptionMessage ElggUpgrade objects must have a value for the description property. */ public function testThrowsOnSaveWithoutDesc() { $this->obj->setPath('test'); $this->obj->title = 'Test'; $this->obj->save(); }
/** * Migrates static pages to be using 'normal' containers and move parent relationship to parent_guid metadata * The previous migration using static pages as containers backfired in places like search, (write) access, listings * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $entity supplied entity * * @return void * @since 5.0 */ public static function migrateContainers($event, $type, $object) { $ia = elgg_set_ignore_access(true); $path = 'admin/upgrades/static/migrate_containers'; $upgrade = new \ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = elgg_echo('admin:upgrades:static:migrate_containers'); $upgrade->description = elgg_echo('admin:upgrades:static:migrate_containers:description'); $upgrade->save(); } elgg_set_ignore_access($ia); }