Elgg  Version master
RemoveIcontime.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrades;
4 
7 
9 
13  public function getVersion(): int {
14  return 2024020901;
15  }
16 
20  public function shouldBeSkipped(): bool {
21  return empty($this->countItems());
22  }
23 
27  public function needsIncrementOffset(): bool {
28  return false;
29  }
30 
34  public function countItems(): int {
35  return elgg_get_metadata($this->getOptions([
36  'count' => true,
37  ]));
38  }
39 
43  public function run(Result $result, $offset): Result {
44  /* @var $metadata \ElggBatch */
45  $metadata = elgg_get_metadata($this->getOptions([
46  'offset' => $offset,
47  ]));
48 
49  /* @var $md \ElggMetadata */
50  foreach ($metadata as $md) {
51  if (!$md->delete()) {
52  $metadata->reportFailure();
53  $result->addFailures();
54  continue;
55  }
56 
57  $result->addSuccesses();
58  }
59 
60  return $result;
61  }
62 
71  protected function getOptions(array $options = []): array {
72  $defaults = [
73  'metadata_names' => 'icontime',
74  'limit' => 50,
75  'batch' => true,
76  'batch_inc_offset' => $this->needsIncrementOffset(),
77  ];
78 
79  return array_merge($defaults, $options);
80  }
81 }
return[ 'admin/delete_admin_notices'=>['access'=> 'admin'], 'admin/menu/save'=>['access'=> 'admin'], 'admin/plugins/activate'=>['access'=> 'admin'], 'admin/plugins/activate_all'=>['access'=> 'admin'], 'admin/plugins/deactivate'=>['access'=> 'admin'], 'admin/plugins/deactivate_all'=>['access'=> 'admin'], 'admin/plugins/set_priority'=>['access'=> 'admin'], 'admin/security/security_txt'=>['access'=> 'admin'], 'admin/security/settings'=>['access'=> 'admin'], 'admin/security/regenerate_site_secret'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['access'=> 'admin'], 'admin/site/flush_cache'=>['access'=> 'admin'], 'admin/site/icons'=>['access'=> 'admin'], 'admin/site/set_maintenance_mode'=>['access'=> 'admin'], 'admin/site/set_robots'=>['access'=> 'admin'], 'admin/site/theme'=>['access'=> 'admin'], 'admin/site/unlock_upgrade'=>['access'=> 'admin'], 'admin/site/settings'=>['access'=> 'admin'], 'admin/upgrade'=>['access'=> 'admin'], 'admin/upgrade/reset'=>['access'=> 'admin'], 'admin/user/ban'=>['access'=> 'admin'], 'admin/user/bulk/ban'=>['access'=> 'admin'], 'admin/user/bulk/delete'=>['access'=> 'admin'], 'admin/user/bulk/unban'=>['access'=> 'admin'], 'admin/user/bulk/validate'=>['access'=> 'admin'], 'admin/user/change_email'=>['access'=> 'admin'], 'admin/user/delete'=>['access'=> 'admin'], 'admin/user/login_as'=>['access'=> 'admin'], 'admin/user/logout_as'=>[], 'admin/user/makeadmin'=>['access'=> 'admin'], 'admin/user/resetpassword'=>['access'=> 'admin'], 'admin/user/removeadmin'=>['access'=> 'admin'], 'admin/user/unban'=>['access'=> 'admin'], 'admin/user/validate'=>['access'=> 'admin'], 'annotation/delete'=>[], 'avatar/upload'=>[], 'comment/save'=>[], 'diagnostics/download'=>['access'=> 'admin'], 'entity/chooserestoredestination'=>[], 'entity/delete'=>[], 'entity/mute'=>[], 'entity/restore'=>[], 'entity/subscribe'=>[], 'entity/trash'=>[], 'entity/unmute'=>[], 'entity/unsubscribe'=>[], 'login'=>['access'=> 'logged_out'], 'logout'=>[], 'notifications/mute'=>['access'=> 'public'], 'plugins/settings/remove'=>['access'=> 'admin'], 'plugins/settings/save'=>['access'=> 'admin'], 'plugins/usersettings/save'=>[], 'register'=>['access'=> 'logged_out', 'middleware'=>[\Elgg\Router\Middleware\RegistrationAllowedGatekeeper::class,],], 'river/delete'=>[], 'settings/notifications'=>[], 'settings/notifications/subscriptions'=>[], 'user/changepassword'=>['access'=> 'public'], 'user/requestnewpassword'=>['access'=> 'public'], 'useradd'=>['access'=> 'admin'], 'usersettings/save'=>[], 'widgets/add'=>[], 'widgets/delete'=>[], 'widgets/move'=>[], 'widgets/save'=>[],]
Definition: actions.php:73
Result of a single BatchUpgrade run.
Definition: Result.php:10
System upgrades are executed synchronously at system upgrade.
needsIncrementOffset()
{Should the run() method receive an offset representing all processed items?If true,...
countItems()
{The total number of items to process during the upgrade.If unknown, Batch::UNKNOWN_COUNT should be r...
getVersion()
{Version of the upgrade.This tells the date when the upgrade was added. It consists of eight digits a...
getOptions(array $options=[])
Get options to metadata queries.
shouldBeSkipped()
{Should this upgrade be skipped?If true, the upgrade will not be performed and cannot be accessed lat...
run(Result $result, $offset)
{Runs upgrade on a single batch of items.If countItems() returns Batch::UNKNOWN_COUNT,...
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
elgg_get_metadata(array $options=[])
Fetch metadata or perform a calculation on them.
Definition: metadata.php:32
$defaults
Generic entity header upload helper.
Definition: header.php:6
if(empty($count)) $offset
Definition: pagination.php:26
$metadata
Output annotation metadata.
Definition: metadata.php:9