Skip to content

Commit

Permalink
Safer max execution assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
tractorcow committed Apr 29, 2020
1 parent 694bb6d commit c08a797
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ClearArchivedRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ class ClearArchivedRecords extends BuildTask
*/
public function run($request)
{
Environment::increaseTimeLimitTo();
Environment::increaseMemoryLimitTo();

$run = $request->getVar('run');
if (!in_array($run, ['dry', 'yes', 'fast'])) {
throw new InvalidArgumentException("Please provide the 'run' argument with either 'yes', 'dry', or 'fast'");
}
$this->setDry($run === 'dry');
$this->setFast($run === 'fast');

// With slow requests, need to increase time limit to 1 hour
if (!$this->isFast() && !$this->isDry()) {
Environment::increaseTimeLimitTo(3600);
Environment::increaseMemoryLimitTo();
}

// Set keep versions
$this->setKeepVersions($request->getVar('keep') ?: self::DEFAULT_KEEP_VERSIONS);

Expand Down

0 comments on commit c08a797

Please sign in to comment.