Elgg  Version 6.1
MigrateDebugConfig.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrades;
4 
8 
10 
14  public function getVersion(): int {
15  return 2024070201;
16  }
17 
21  public function shouldBeSkipped(): bool {
22  $current_value = _elgg_services()->configTable->get('debug');
23  $supported_levels = [
24  LogLevel::DEBUG,
25  LogLevel::INFO,
26  LogLevel::NOTICE,
27  LogLevel::WARNING,
28  LogLevel::ERROR,
29  LogLevel::CRITICAL,
30  LogLevel::ALERT,
31  LogLevel::EMERGENCY
32  ];
33 
34  return empty($current_value) || in_array($current_value, $supported_levels);
35  }
36 
40  public function needsIncrementOffset(): bool {
41  return false;
42  }
43 
47  public function countItems(): int {
48  return 1;
49  }
50 
54  public function run(Result $result, $offset): Result {
55  $current_value = _elgg_services()->configTable->get('debug');
56 
57  $new_value = LogLevel::CRITICAL;
58  switch($current_value) {
59  case 'INFO':
60  $new_value = LogLevel::INFO;
61  break;
62  case 'NOTICE':
63  $new_value = LogLevel::NOTICE;
64  break;
65  case 'WARNING':
66  $new_value = LogLevel::WARNING;
67  break;
68  case 'ERROR':
69  $new_value = LogLevel::ERROR;
70  break;
71  }
72 
73  if (_elgg_services()->configTable->set('debug', $new_value)) {
74  $result->addSuccesses();
75  } else {
76  $result->addFailures();
77  }
78 
79  return $result;
80  }
81 }
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
run(Result $result, $offset)
{}
Result of a single BatchUpgrade run.
Definition: Result.php:10
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
System upgrades are executed synchronously at system upgrade.
$current_value
Elgg switch input.
Definition: switch.php:11