Elgg  Version 6.1
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 */
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 }
$defaults
Generic entity header upload helper.
Definition: header.php:6
addFailures(int $num=1)
Increment failure count.
Definition: Result.php:53
if(empty($count)) $offset
Definition: pagination.php:26
addSuccesses(int $num=1)
Set an item (or items) as successfully upgraded.
Definition: Result.php:73
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
getOptions(array $options=[])
Get options to metadata queries.
run(Result $result, $offset)
{}
Result of a single BatchUpgrade run.
Definition: Result.php:10
elgg_get_metadata(array $options=[])
Fetch metadata or perform a calculation on them.
Definition: metadata.php:32
$metadata
Output annotation metadata.
Definition: metadata.php:9
System upgrades are executed synchronously at system upgrade.