Elgg  Version 3.0
DeleteOldPlugins.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrades;
4 
7 
11 class DeleteOldPlugins implements SystemUpgrade {
12 
13  protected $plugins = [
14  'htmlawed',
15  'aalborg_theme',
16  'legacy_urls',
17  'logbrowser',
18  'logrotate',
19  'twitter_api',
20  ];
21 
25  public function getVersion() {
26  return 2018041801;
27  }
28 
32  public function shouldBeSkipped() {
33  return false;
34  }
35 
39  public function needsIncrementOffset() {
40  return false;
41  }
42 
46  public function countItems() {
47  return count($this->plugins);
48  }
49 
53  public function run(Result $result, $offset) {
54  foreach ($this->plugins as $id) {
56 
57  if (!$plugin) {
58  $result->addSuccesses(1);
59  continue;
60  }
61 
62  _elgg_services()->logger->disable();
63  if (!$plugin->isValid()) {
64  if ($plugin->delete()) {
65  $result->addSuccesses(1);
66  } else {
67  $result->addFailures(1);
68  $result->addError($plugin->getError());
69  }
70  }
71  _elgg_services()->logger->enable();
72  }
73  }
74 
75 }
$plugin
run(Result $result, $offset)
{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 of the batch (this must be returned) Number to skip when processingResult}
if(!$count) $offset
Definition: pagination.php:26
addSuccesses($num=1)
Set an item (or items) as successfully upgraded.
Definition: Result.php:68
$id
River item delete action.
Definition: delete.php:6
addFailures($num=1)
Increment failure count.
Definition: Result.php:49
Remove entities associated with plugins removed in 3.0.
addError($message)
Add new error message to the batch.
Definition: Result.php:24
Result of a single BatchUpgrade run.
Definition: Result.php:8
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.bool}
System upgrades are executed synchronously at system upgrade.
countItems()
{The total number of items to process during the upgrade.If unknown, Batch::UNKNOWN_COUNT should be r...
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
shouldBeSkipped()
{Should this upgrade be skipped?If true, the upgrade will not be performed and cannot be accessed lat...
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:28
getVersion()
{Version of the upgrade.This tells the date when the upgrade was added. It consists of eight digits a...