These are listed in admin/upgrades and allow for ajax upgrades.
Inheritance: extends ElggObject
Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
 public function testCanFindUpgradesByFullUrl()
 {
     $this->obj->_callable_egefps = array($this, 'mock_egefps_for_full_url');
     $this->obj->upgrade_url = elgg_normalize_url('test');
     $upgrade = $this->obj->getUpgradeFromPath('test');
     $this->assertTrue((bool) $upgrade);
     $this->assertSame('test', $upgrade->upgrade_url);
 }
Exemplo n.º 4
0
 public function testCanInstantiateBatchRunner()
 {
     $this->obj->setClass('\\InvalidClass');
     $this->assertFalse($this->obj->getBatch());
     $this->obj->setClass(\Elgg\Upgrade\InvalidBatch::class);
     $this->assertFalse($this->obj->getBatch());
     $this->obj->setClass(\Elgg\Upgrade\TestBatch::class);
     $this->assertInstanceOf(\Elgg\Upgrade\TestBatch::class, $this->obj->getBatch());
 }
Exemplo n.º 5
0
 /**
  * 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);
 }
Exemplo n.º 6
0
/**
 * 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);
}
Exemplo n.º 7
0
/**
 * 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);
}
Exemplo n.º 8
0
    /**
     * 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);
    }
Exemplo n.º 9
0
 /**
  * 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);
 }
Exemplo n.º 10
0
<?php

/**
 * Convert discussion replies from annotations to entities
 *
 * Run for 2 seconds per request as set by $batch_run_time_in_secs. This includes
 * the engine loading time.
 */
// from engine/start.php
global $START_MICROTIME;
$batch_run_time_in_secs = 2;
if (get_input('upgrade_completed')) {
    // set the upgrade as completed
    $factory = new ElggUpgrade();
    $upgrade = $factory->getUpgradeFromURL('/admin/upgrades/discussion_replies');
    if ($upgrade instanceof ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
// Offset is the total amount of errors so far. We skip these
// annotations to prevent them from possibly repeating the same error.
$offset = get_input('offset', 0);
$limit = 50;
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
// don't want any event or plugin hook handlers from plugins to run
$original_events = _elgg_services()->events;
$original_hooks = _elgg_services()->hooks;
_elgg_services()->events = new Elgg\EventsService();
_elgg_services()->hooks = new Elgg\PluginHooksService();
Exemplo n.º 11
0
<?php

/**
 * Convert comment annotations to entities
 *
 * Run for 2 seconds per request as set by $batch_run_time_in_secs. This includes
 * the engine loading time.
 */
// from engine/start.php
global $START_MICROTIME;
$batch_run_time_in_secs = 2;
// if upgrade has run correctly, mark it done
if (get_input('upgrade_completed')) {
    // set the upgrade as completed
    $factory = new ElggUpgrade();
    $upgrade = $factory->getUpgradeFromPath('admin/upgrades/comments');
    if ($upgrade instanceof ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
// Offset is the total amount of errors so far. We skip these
// comments to prevent them from possibly repeating the same error.
$offset = get_input('offset', 0);
$limit = 50;
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
// don't want any event or plugin hook handlers from plugins to run
$original_events = _elgg_services()->events;
$original_hooks = _elgg_services()->hooks;
_elgg_services()->events = new Elgg_EventsService();
Exemplo n.º 12
0
<?php

/**
 * Data dirs upgrade page
 */
// Upgrade also possible hidden users. 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);
$factory = new ElggUpgrade();
$upgrade = $factory->getUpgradeFromURL('/admin/upgrades/datadirs');
if ($upgrade->isCompleted()) {
    $count = 0;
} else {
    $helper = new Elgg_Upgrades_Helper2013022000(elgg_get_site_entity()->guid, elgg_get_config('dbprefix'));
    $helper->forgetFailures();
    $count = $helper->countUnmigratedUsers();
}
echo elgg_view('admin/upgrades/view', array('count' => $count, 'action' => 'action/admin/upgrades/upgrade_datadirs'));
access_show_hidden_entities($access_status);
Exemplo n.º 13
0
<?php

/**
 * Migrate containers of static pages
 */
$success_count = 0;
$error_count = 0;
if (get_input('upgrade_completed')) {
    // set the upgrade as completed
    $factory = new \ElggUpgrade();
    $upgrade = $factory->getUpgradeFromPath('admin/upgrades/static/migrate_containers');
    if ($upgrade instanceof \ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$dbprefix = elgg_get_config('dbprefix');
$name_id = elgg_get_metastring_id('parent_guid');
$batch = new \ElggBatch('elgg_get_entities', ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'wheres' => ["e.guid NOT IN (SELECT entity_guid FROM {$dbprefix}metadata WHERE name_id = {$name_id})"]]);
$batch->setIncrementOffset(false);
foreach ($batch as $page) {
    $success_count++;
    if ($page->parent_guid) {
        // already converted
        continue;
    }
    $root = $page->getRootPage();
    if ($root instanceof \StaticPage) {
        $page->parent_guid = $page->container_guid;
Exemplo n.º 14
0
            foreach ($files as $file) {
                $file_name = $file['file'];
                $old_file->setFilename("events/{$event->guid}/files/{$file_name}");
                if ($old_file->exists()) {
                    $new_file->setFilename("files/{$file_name}");
                    $new_file->open('write');
                    if ($new_file->write($old_file->grabFile())) {
                        $old_file->delete();
                    }
                    $new_file->close();
                }
            }
        }
    }
    $offset++;
    $session->set('event_manager_files_migration_offset', $offset);
    $success_count++;
}
access_show_hidden_entities($access_status);
if ($start_offset === $offset) {
    // no new entities found to process
    // set the upgrade as completed
    $factory = new \ElggUpgrade();
    $upgrade = $factory->getUpgradeFromPath('admin/upgrades/migrate_files_to_event');
    if ($upgrade instanceof \ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
// Give some feedback for the UI
echo json_encode(['numSuccess' => $success_count, 'numErrors' => 0]);
Exemplo n.º 15
0
<?php

/**
 * Convert discussion replies from annotations to entities
 *
 * Run for 2 seconds per request as set by $batch_run_time_in_secs. This includes
 * the engine loading time.
 */
// from engine/start.php
global $START_MICROTIME;
$batch_run_time_in_secs = 2;
if (get_input('upgrade_completed')) {
    // set the upgrade as completed
    $factory = new ElggUpgrade();
    $upgrade = $factory->getUpgradeFromPath('admin/upgrades/discussion_replies');
    if ($upgrade instanceof ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
// Offset is the total amount of errors so far. We skip these
// annotations to prevent them from possibly repeating the same error.
$offset = get_input('offset', 0);
$limit = 50;
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
// don't want any event or plugin hook handlers from plugins to run
$original_events = _elgg_services()->events;
$original_hooks = _elgg_services()->hooks;
_elgg_services()->events = new Elgg\EventsService();
_elgg_services()->hooks = new Elgg\PluginHooksService();
 * in actions/admin/upgrades/upgrade_discussion_replies.php for that.
 *
 * This upgrade must be run even if the groups plugin is disabled because the
 * script will be removed in Elgg 1.10 and we don't want anyone to get stuck
 * with old annotation replies just because the groups plugin was not enabled
 * when site was upgraded from 1.8.
 */
// Register subtype and class for discussion replies
if (get_subtype_id('object', 'discussion_reply')) {
    update_subtype('object', 'discussion_reply', 'ElggDiscussionReply');
} else {
    add_subtype('object', 'discussion_reply', 'ElggDiscussionReply');
}
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$ia = elgg_set_ignore_access(true);
$discussion_replies = elgg_get_annotations(array('annotation_names' => 'group_topic_post', 'count' => true));
// Notify administrator only if there are existing discussion replies
if ($discussion_replies) {
    $path = "admin/upgrades/discussion_replies";
    $upgrade = new \ElggUpgrade();
    // Create the upgrade if one with the same URL doesn't already exist
    if (!$upgrade->getUpgradeFromPath($path)) {
        $upgrade->setPath($path);
        $upgrade->title = 'Group Discussions Upgrade';
        $upgrade->description = 'Group discussions 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);
Exemplo n.º 17
0
// don"t want any event or plugin hook handlers from plugins to run
$original_events = _elgg_services()->events;
$original_hooks = _elgg_services()->hooks;
_elgg_services()->events = new Elgg_EventsService();
_elgg_services()->hooks = new Elgg_PluginHooksService();
elgg_register_plugin_hook_handler("permissions_check", "all", "elgg_override_permissions");
elgg_register_plugin_hook_handler("container_permissions_check", "all", "elgg_override_permissions");
_elgg_services()->db->disableQueryCache();
$success_count = 0;
$error_count = 0;
while (microtime(true) - $START_MICROTIME < $batch_run_time_in_secs) {
    $options = array("type" => "user", "relationship" => CONTENT_SUBSCRIPTIONS_SUBSCRIPTION, "inverse_relationship" => true, "count" => true);
    $count = elgg_get_entities_from_relationship($options);
    if (!$count) {
        // no old subscriptions left
        $factory = new ElggUpgrade();
        $upgrade = $factory->getUpgradeFromPath("admin/upgrades/content_subscriptions");
        if ($upgrade instanceof ElggUpgrade) {
            $upgrade->setCompleted();
        }
        break;
    }
    $options["count"] = false;
    $options["offset"] = $offset;
    $options["limit"] = $limit;
    $users = elgg_get_entities_from_relationship($options);
    foreach ($users as $user) {
        $error_counter = 0;
        $subscription_options = array("relationship" => CONTENT_SUBSCRIPTIONS_SUBSCRIPTION, "relationship_guid" => $user->getGUID(), "limit" => false);
        $batch = new ElggBatch("elgg_get_entities_from_relationship", $subscription_options);
        $batch->setIncrementOffset(false);
Exemplo n.º 18
0
<?php

// 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);
$count = 0;
// make sure no left over from previous run
$session = elgg_get_session();
$session->remove('blog_tools_move_icon_offset');
// check if upgrade is done
$path = 'admin/upgrades/blog_tools_move_icons';
$factory = new \ElggUpgrade();
$upgrade = $factory->getUpgradeFromPath($path);
if (empty($upgrade) || !$upgrade->isCompleted()) {
    // get the count off the items to move
    $count = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => 'blog', 'metadata_name' => 'icontime', 'count' => true]);
}
echo elgg_view('output/longtext', ['value' => elgg_echo('admin:upgrades:blog_tools_move_icons:description')]);
echo elgg_view('admin/upgrades/view', ['count' => $count, 'action' => 'action/blog_tools/upgrades/move_icons']);
access_show_hidden_entities($access_status);
Exemplo n.º 19
0
// don"t want any event or plugin hook handlers from plugins to run
$original_events = _elgg_services()->events;
$original_hooks = _elgg_services()->hooks;
_elgg_services()->events = new Elgg_EventsService();
_elgg_services()->hooks = new Elgg_PluginHooksService();
elgg_register_plugin_hook_handler("permissions_check", "all", "elgg_override_permissions");
elgg_register_plugin_hook_handler("container_permissions_check", "all", "elgg_override_permissions");
_elgg_services()->db->disableQueryCache();
$success_count = 0;
$error_count = 0;
while (microtime(true) - $START_MICROTIME < $batch_run_time_in_secs) {
    $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) {
        // no old subscriptions left
        $factory = new ElggUpgrade();
        $upgrade = $factory->getUpgradeFromPath("admin/upgrades/thewire_tools_mentions");
        if ($upgrade instanceof ElggUpgrade) {
            $upgrade->setCompleted();
        }
        break;
    }
    $options["count"] = false;
    $options["offset"] = $offset;
    $options["limit"] = $limit;
    $users = elgg_get_entities_from_plugin_user_settings($options);
    foreach ($users as $user) {
        $setting = elgg_get_plugin_user_setting("notify_mention", $user->getGUID(), "thewire_tools");
        if ($setting == "yes") {
            $notification_settings = get_user_notification_settings($user->getGUID());
            if (!empty($notification_settings)) {
Exemplo n.º 20
0
<?php

/**
 * Convert comment annotations to entities
 * 
 * Run for 2 seconds per request as set by $batch_run_time_in_secs. This includes
 * the engine loading time.
 */
// from engine/start.php
global $START_MICROTIME;
$batch_run_time_in_secs = 2;
// if upgrade has run correctly, mark it done
if (get_input('upgrade_completed')) {
    // set the upgrade as completed
    $factory = new ElggUpgrade();
    $upgrade = $factory->getUpgradeFromURL('/admin/upgrades/comments');
    if ($upgrade instanceof ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
// Offset is the total amount of errors so far. We skip these
// comments to prevent them from possibly repeating the same error.
$offset = get_input('offset', 0);
$limit = 50;
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
// don't want any event or plugin hook handlers from plugins to run
$original_events = _elgg_services()->events;
$original_hooks = _elgg_services()->hooks;
_elgg_services()->events = new Elgg_EventsService();
Exemplo n.º 21
0
<?php

/**
 * Migrate timestamp of events
 */
$success_count = 0;
$error_count = 0;
if (get_input('upgrade_completed')) {
    // set the upgrade as completed
    $factory = new \ElggUpgrade();
    $upgrade = $factory->getUpgradeFromPath('admin/upgrades/convert_timestamps');
    if ($upgrade instanceof \ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$batch = new \ElggBatch('elgg_get_entities_from_metadata', ['type' => 'object', 'subtype' => \Event::SUBTYPE, 'limit' => 25, 'metadata_names' => ['start_day']]);
$batch->setIncrementOffset(false);
foreach ($batch as $event) {
    $success_count++;
    if ($event->event_start) {
        // already converted
        continue;
    }
    $event_start = gmmktime(0, 0, 0, date('m', $event->start_day), date('d', $event->start_day), date('Y', $event->start_day));
    if ($event->start_time) {
        $hours = date('H', $event->start_time);
        $minutes = date('i', $event->start_time);
        $event_start += $minutes * 60;
Exemplo n.º 22
0
<?php

/**
 * Data dirs upgrade page
 */
// Upgrade also possible hidden users. 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);
$factory = new ElggUpgrade();
$upgrade = $factory->getUpgradeFromPath('admin/upgrades/datadirs');
if ($upgrade->isCompleted()) {
    $count = 0;
} else {
    $helper = new Elgg_Upgrades_Helper2013022000(elgg_get_site_entity()->guid, elgg_get_config('dbprefix'));
    $helper->forgetFailures();
    $count = $helper->countUnmigratedUsers();
}
echo elgg_view('admin/upgrades/view', array('count' => $count, 'action' => 'action/admin/upgrades/upgrade_datadirs'));
access_show_hidden_entities($access_status);
Exemplo n.º 23
0
 /**
  * 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);
 }
 * 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);
Exemplo n.º 25
0
<?php

use Elgg\EntityDirLocator;
use hypeJunction\Scraper\ScraperService;
if (get_input('upgrade_completed')) {
    $factory = new ElggUpgrade();
    $upgrade = $factory->getUpgradeFromPath('admin/upgrades/scraper/move_to_db');
    if ($upgrade instanceof ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
$svc = ScraperService::getInstance();
$site = elgg_get_site_entity();
$dataroot = elgg_get_config('dataroot');
$dir = new EntityDirLocator($site->guid);
$paths = elgg_get_file_list($dataroot . $dir . 'scraper_cache/resources/');
$original_time = microtime(true);
$time_limit = 4;
$success_count = 0;
$error_count = 0;
$response = [];
while (count($paths) > 0 && microtime(true) - $original_time < $time_limit) {
    $path = array_shift($paths);
    error_log((string) count($paths));
    $response['upgraded'][] = $path;
    $success_count++;
    $basename = pathinfo($path, PATHINFO_BASENAME);
    $file = new ElggFile();
    $file->owner_guid = $site->guid;
    $file->setFilename("scraper_cache/resources/{$basename}");