Elgg  Version 3.0
SetSecurityConfigDefaults.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrades;
4 
7 
13 
14  private $defaults = [
15  'security_protect_upgrade' => true,
16  'security_notify_admins' => true,
17  'security_notify_user_password' => true,
18  'security_email_require_password' => true,
19  ];
20 
24  public function getVersion() {
25  return 2017080950;
26  }
27 
31  public function needsIncrementOffset() {
32  return false;
33  }
34 
38  public function shouldBeSkipped() {
39 
40  foreach ($this->defaults as $name => $value) {
41  $existing_value = elgg_get_config($name);
42  if (is_null($existing_value)) {
43  return false;
44  }
45  }
46 
47  return true;
48  }
49 
53  public function countItems() {
54  return count($this->defaults);
55  }
56 
60  public function run(Result $result, $offset) {
61 
62  foreach ($this->defaults as $name => $value) {
63  $existing_value = elgg_get_config($name);
64  if (is_null($existing_value)) {
66  }
67 
68  $result->addSuccesses();
69  }
70  }
71 
72 }
Interface to be implement for asynchronous upgrades, i.e.
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(!$user||!$user->canDelete()) $name
Definition: delete.php:22
Set default security config values We run this async to allow sites to upgrade without having to deal...
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}
if(!$count) $offset
Definition: pagination.php:26
getVersion()
{Version of the upgrade.This tells the date when the upgrade was added. It consists of eight digits a...
addSuccesses($num=1)
Set an item (or items) as successfully upgraded.
Definition: Result.php:68
elgg_save_config($name, $value)
Save a configuration setting.
Result of a single BatchUpgrade run.
Definition: Result.php:8
countItems()
{The total number of items to process during the upgrade.If unknown, Batch::UNKNOWN_COUNT should be r...
$value
Definition: debugging.php:7
shouldBeSkipped()
{Should this upgrade be skipped?If true, the upgrade will not be performed and cannot be accessed lat...
elgg_get_config($name, $default=null)
Get an Elgg configuration value.