9 use Elgg\Traits\TimeUsing;
34 parent::initializeAttributes();
38 $this->attributes[
'subtype'] =
'elgg_upgrade';
39 $this->attributes[
'container_guid'] =
$site->guid;
40 $this->attributes[
'owner_guid'] =
$site->guid;
43 $this->is_completed =
false;
53 return elgg_echo(
"{$component}:upgrade:{$version}:title");
62 $this->setStartTime();
63 $this->setCompletedTime();
64 $this->is_completed =
true;
75 return (bool) $this->is_completed;
84 public function getID(): ?string {
94 if (!isset($this->id)) {
98 $parts = explode(
':', $this->
id);
109 if (!isset($this->id)) {
113 $parts = explode(
':', $this->
id);
124 return is_subclass_of($this->class, \
Elgg\Upgrade\AsynchronousUpgrade::class);
135 }
catch (ElggInvalidArgumentException $ex) {
137 $loglevel = $this->isCompleted() ? \Psr\Log\LogLevel::INFO : \Psr\Log\LogLevel::ERROR;
138 elgg_log($ex->getMessage(), $loglevel);
147 if (preg_match(
'/^[0-9]{10}$/',
$version) === 0) {
148 elgg_log(
"Upgrade {$this->class} returned an invalid version: {$version}");
163 $this->completed_time =
$time ?? $this->getCurrentTime()->getTimestamp();
172 return (int) $this->completed_time;
181 $this->is_completed = false;
184 unset($this->completed_time);
185 unset($this->processed);
186 unset($this->start_time);
198 if (isset($this->start_time)) {
202 $this->start_time =
$time ?? $this->getCurrentTime()->getTimestamp();
211 return (int) $this->start_time;
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/clear'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['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', 'controller'=> \Elgg\Diagnostics\DownloadController::class,], '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'=>[],]
if(! $annotation instanceof ElggAnnotation) $time
Represents an upgrade that runs outside the upgrade.php script.
getComponent()
Get the component where the upgrade originated ('core' or a plugin ID)
getBatch()
Return instance of the class that processes the data.
getDisplayName()
{{Get the entity's display name.string The title or name of this entity.}}
setCompleted()
Mark this upgrade as completed.
initializeAttributes()
{{Initialize the attributes array.This is vital to distinguish between metadata and base parameters....
getCompletedTime()
Gets the time when the upgrade completed.
getVersion()
Get the version of the upgrade in the format <yyymmddhh>
isCompleted()
Has this upgrade completed?
setStartTime(?int $time=null)
Sets the timestamp for when the upgrade started.
setCompletedTime(?int $time=null)
Sets the timestamp for when the upgrade completed.
getStartTime()
Gets the time when the upgrade completed.
reset()
Resets the update in order to be able to run it again.
isAsynchronous()
Check if the upgrade should be run asynchronously.
getID()
Get the unique ID for the upgrade in the format <plugin_name>:<yyymmddhh>
Exception thrown if an argument is not of the expected type.
Exception thrown if a value does not match with a set of values.
Long running upgrades should implement this interface.
if(! $entity instanceof \ElggUpgrade) $component
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
_elgg_services()
Get the global service provider.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
elgg_get_site_entity()
Get the current site entity.
elgg_trigger_event(string $event, string $type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event,...
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.