Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispenny committed May 1, 2023
1 parent e98f41f commit d839ad4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Job/StaticCacheFullBuildJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,20 @@ protected function getAllLivePageURLs(): array
$urls = [];
$this->extend('beforeGetAllLivePageURLs', $urls);
$livePages = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE);

foreach ($livePages as $page) {
if ($page->hasExtension(PublishableSiteTree::class) || $page instanceof StaticallyPublishable) {
$urls = array_merge($urls, $page->urlsToCache());
}
}

$this->extend('afterGetAllLivePageURLs', $urls);

// @TODO look here when integrating subsites
// if (class_exists(Subsite::class)) {
// Subsite::disable_subsite_filter(true);
// }

return $urls;
}

Expand Down
10 changes: 8 additions & 2 deletions src/Task/StaticCacheFullBuildTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\StaticPublishQueue\Task;

use DateTime;
use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Injector\Injector;
Expand All @@ -15,6 +16,8 @@

class StaticCacheFullBuildTask extends BuildTask
{
protected $title = 'Static Cache Full Build';

/**
* Queue up a StaticCacheFullBuildJob
* Check for startAfter param and do some sanity checking
Expand Down Expand Up @@ -45,6 +48,7 @@ public function run($request)
$existing->Created,
$existing->StartAfter ? 'and set to start after ' . $existing->StartAfter : ''
));

return false;
}

Expand All @@ -61,12 +65,14 @@ public function run($request)
$timestamp = strtotime($today . ' ' . $startTime);
$dayWord = 'today';
}
$startAfter = (new \DateTime())->setTimestamp($timestamp);
$thisTimeTomorrow = (new \DateTime())->setTimestamp(strtotime($now . ' +1 day'))->getTimestamp();

$startAfter = (new DateTime())->setTimestamp($timestamp);
$thisTimeTomorrow = (new DateTime())->setTimestamp(strtotime($now . ' +1 day'))->getTimestamp();

// sanity check that we are in the next 24 hours - prevents some weird stuff sneaking through
if ($startAfter->getTimestamp() > $thisTimeTomorrow || $startAfter->getTimestamp() < $now->getTimestamp()) {
$this->log('Invalid startAfter parameter passed. Please ensure the time format is HHmm e.g. 1300');

return false;
}

Expand Down

0 comments on commit d839ad4

Please sign in to comment.