Elgg  Version master
MigrateDebugConfig.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrades;
4 
7 use Psr\Log\LogLevel;
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 }
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.
getVersion()
{Version of the upgrade.This tells the date when the upgrade was added. It consists of eight digits a...
countItems()
{The total number of items to process during the upgrade.If unknown, Batch::UNKNOWN_COUNT should be r...
needsIncrementOffset()
{Should the run() method receive an offset representing all processed items?If true,...
run(Result $result, $offset)
{Runs upgrade on a single batch of items.If countItems() returns Batch::UNKNOWN_COUNT,...
shouldBeSkipped()
{Should this upgrade be skipped?If true, the upgrade will not be performed and cannot be accessed lat...
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
if(empty($count)) $offset
Definition: pagination.php:26
$current_value
Elgg switch input.
Definition: switch.php:11