Elgg  Version 4.3
Public Member Functions | Public Attributes | List of all members
Elgg\Upgrade\Batch Interface Reference

Long running upgrades should implement this interface. More...

Inheritance diagram for Elgg\Upgrade\Batch:
Elgg\Upgrade\AsynchronousUpgrade Elgg\Upgrade\SystemUpgrade Elgg\Upgrades\AlterDatabaseToMultiByteCharset Elgg\Upgrades\ContentOwnerSubscriptions Elgg\Upgrades\MigrateACLNotificationPreferences Elgg\Upgrades\NotificationsPrefix Elgg\Upgrades\RemoveOrphanedThreadedComments Elgg\Upgrades\ChangeUserNotificationSettingsNamespace Elgg\Upgrades\DeleteDiagnosticsPlugin Elgg\Upgrades\DeleteNotificationsPlugin

Public Member Functions

 getVersion ()
 Version of the upgrade. More...
 shouldBeSkipped ()
 Should this upgrade be skipped? More...
 needsIncrementOffset ()
 Should the run() method receive an offset representing all processed items? More...
 countItems ()
 The total number of items to process during the upgrade. More...
 run (Result $result, $offset)
 Runs upgrade on a single batch of items. More...

Public Attributes

const UNKNOWN_COUNT = -1
 countItems() should return this if it doesn't know how many items remain. More...

Detailed Description

Long running upgrades should implement this interface.


Definition at line 10 of file Batch.php.

Member Function Documentation

Elgg\Upgrade\Batch::countItems ( )
Elgg\Upgrade\Batch::getVersion ( )

Version of the upgrade.

This tells the date when the upgrade was added. It consists of eight digits and is in format yyyymmddnn where:

  • yyyy is the year
  • mm is the month (with leading zero)
  • dd is the day (with leading zero)
  • nn is an incrementing number (starting from 00) that is used in case two separate upgrades have been added during the same day
int E.g. 2016123101

Implemented in Elgg\Upgrades\AlterDatabaseToMultiByteCharset, Elgg\Upgrades\NotificationsPrefix, Elgg\Upgrades\ChangeUserNotificationSettingsNamespace, Elgg\Upgrades\ContentOwnerSubscriptions, Elgg\Upgrades\MigrateACLNotificationPreferences, Elgg\Upgrades\DeleteDiagnosticsPlugin, Elgg\Upgrades\DeleteNotificationsPlugin, and Elgg\Upgrades\RemoveOrphanedThreadedComments.

Elgg\Upgrade\Batch::needsIncrementOffset ( )

Should the run() method receive an offset representing all processed items?

If true, run() will receive as $offset the number of items already processed. This is useful if you are only modifying data, and need to use the $offset in a function like elgg_get_entities*() to know how many to skip over.

If false, run() will receive as $offset the total number of failures. This should be used if your process deletes or moves data out of the way of the process. E.g. if you delete 50 objects on each run(), you may still use the $offset to skip objects that already failed once.


Implemented in Elgg\Upgrades\AlterDatabaseToMultiByteCharset, Elgg\Upgrades\NotificationsPrefix, Elgg\Upgrades\RemoveOrphanedThreadedComments, Elgg\Upgrades\ChangeUserNotificationSettingsNamespace, Elgg\Upgrades\ContentOwnerSubscriptions, Elgg\Upgrades\MigrateACLNotificationPreferences, Elgg\Upgrades\DeleteDiagnosticsPlugin, and Elgg\Upgrades\DeleteNotificationsPlugin.

Elgg\Upgrade\Batch::run ( Result  $result,

Runs upgrade on a single batch of items.

If countItems() returns Batch::UNKNOWN_COUNT, this method must call $result->markCompleted() when the upgrade is complete.

Result$resultResult of the batch (this must be returned)
int$offsetNumber to skip when processing

Implemented in Elgg\Upgrades\AlterDatabaseToMultiByteCharset, Elgg\Upgrades\ChangeUserNotificationSettingsNamespace, Elgg\Upgrades\MigrateACLNotificationPreferences, Elgg\Upgrades\ContentOwnerSubscriptions, Elgg\Upgrades\NotificationsPrefix, Elgg\Upgrades\DeleteDiagnosticsPlugin, Elgg\Upgrades\DeleteNotificationsPlugin, and Elgg\Upgrades\RemoveOrphanedThreadedComments.

Elgg\Upgrade\Batch::shouldBeSkipped ( )

Member Data Documentation

const Elgg\Upgrade\Batch::UNKNOWN_COUNT = -1

countItems() should return this if it doesn't know how many items remain.

Definition at line 15 of file Batch.php.

The documentation for this interface was generated from the following file: