59 $this->
count = $this->batch->countItems();
60 $this->processed = (int) $upgrade->processed;
61 $this->offset = (
int) $upgrade->offset;
71 public function loop(
int $max_duration = null):
void {
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();
116 $this->batch->run($this->result, $this->offset);
117 }
catch (\Exception $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) {
189 if (!isset($max_duration)) {
206 if ($this->batch->shouldBeSkipped()) {
210 if ($this->result->wasMarkedComplete()) {
219 if (!$this->batch->needsIncrementOffset()) {
221 return ($this->batch->countItems() - $this->result->getFailureCount()) <= 0;
loop(int $max_duration=null)
Run upgrade loop for a preset number of seconds.
Exception thrown if an error which can only be found on runtime occurs.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
runBatch(ProgressBar $progress)
Run batch.
elgg_register_success_message(string|array $options)
Registers a success system message.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
isCompleted()
Check if upgrade has completed.
trait Loggable
Enables adding a logger.
getBatch()
Return instance of the class that processes the data.
if(empty($guid)) $upgrade
const UNKNOWN_COUNT
countItems() should return this if it doesn't know how many items remain.
Represents an upgrade that runs outside of the upgrade.php script.
setLogger(LoggerInterface $logger=null)
Set (or remove) the logger.
__construct(protected\ElggUpgrade $upgrade, protected Result $result, protected Progress $progress, Logger $logger)
Constructor.
Result of a single BatchUpgrade run.
canContinue($started, int $max_duration=null)
Check if the loop cand and should continue.
elgg_register_error_message(string|array $options)
Registers a error system message.
getLogger()
Returns logger.
$ts
CSRF security token view for use with secure forms.
report()
Report loop results.
Upgrade loop Executes upgrade batches for a given duration of time.