8 use Elgg\Traits\Loggable;
 
    9 use Symfony\Component\Console\Helper\ProgressBar;
 
   48         $this->setLogger($logger);
 
   59         $this->count = $this->batch->countItems();
 
   60         $this->processed = (int) 
$upgrade->processed;
 
   61         $this->offset = (
int) 
$upgrade->offset;
 
   74         $this->upgrade->setStartTime();
 
   75         $progress = $this->progress->start($this->upgrade->getDisplayName(), $this->count);
 
   81         $this->progress->finish($progress);
 
   91         if ($this->result->getFailureCount()) {
 
   95             $this->upgrade->processed = 0;
 
   96             $this->upgrade->offset = 0;
 
  100             $this->upgrade->setCompleted();
 
  101             $this->result->markComplete();
 
  114     protected function runBatch(ProgressBar $progress): void {
 
  116             $this->batch->run($this->result, $this->offset);
 
  117         } 
catch (\Exception $e) {
 
  118             $this->getLogger()->error($e);
 
  120             $this->result->addError($e->getMessage());
 
  121             $this->result->addFailures(1);
 
  124         $failure_count = $this->result->getFailureCount();
 
  125         $success_count = $this->result->getSuccessCount();
 
  127         $total = $this->upgrade->processed + $failure_count + $success_count;
 
  129         $progress->advance($total - $this->processed);
 
  131         if ($this->batch->needsIncrementOffset()) {
 
  135             $this->offset = $total;
 
  139             $this->offset = $this->upgrade->offset + $failure_count;
 
  142         $this->processed = $total;
 
  151         $upgrade_name = $this->upgrade->getDisplayName();
 
  153         if ($this->upgrade->isCompleted()) {
 
  154             $ts = $this->upgrade->getCompletedTime();
 
  155             $dt = new \DateTime();
 
  156             $dt->setTimestamp((
int) 
$ts);
 
  159             if ($this->result->getFailureCount()) {
 
  163                     $this->result->getFailureCount(),
 
  175         foreach ($this->result->getErrors() as 
$error) {
 
  176             $this->getLogger()->error(
$error);
 
  189         if (!isset($max_duration)) {
 
  193         if ($max_duration > 0 && (microtime(
true) - 
$started) >= $max_duration) {
 
  197         return !$this->isCompleted();
 
  206         if ($this->batch->shouldBeSkipped()) {
 
  210         if ($this->result->wasMarkedComplete()) {
 
  214         if ($this->count === Batch::UNKNOWN_COUNT) {
 
  219         if (!$this->batch->needsIncrementOffset()) {
 
  221             return ($this->batch->countItems() - $this->result->getFailureCount()) <= 0;
 
if(empty($guid)) $upgrade
Represents an upgrade that runs outside of the upgrade.php script.
Exception thrown if an error which can only be found on runtime occurs.
Upgrade loop Executes upgrade batches for a given duration of time.
loop(?int $max_duration=null)
Run upgrade loop for a preset number of seconds.
runBatch(ProgressBar $progress)
Run batch.
__construct(protected \ElggUpgrade $upgrade, protected Result $result, protected Progress $progress, Logger $logger)
Constructor.
canContinue($started, ?int $max_duration=null)
Check if the loop can and should continue.
report()
Report loop results.
isCompleted()
Check if upgrade has completed.
Result of a single BatchUpgrade run.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_register_success_message(string|array $options)
Registers a success system message.
elgg_register_error_message(string|array $options)
Registers a error system message.
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
$ts
CSRF security token view for use with secure forms.