Skip to content

Commit

Permalink
ENH Do not rely on flush variable
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 22, 2024
1 parent 64708df commit 81d5c15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Filters/CachedContentFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace SilverStripe\VersionFeed\Filters;

use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Kernel;

/**
* Caches results of a callback
Expand All @@ -24,7 +26,7 @@ public function getContent($key, $callback)

// Return cached value if available
$cacheEnabled = Config::inst()->get(CachedContentFilter::class, 'cache_enabled');
$result = (isset($_GET['flush']) || !$cacheEnabled)
$result = (Injector::inst()->get(Kernel::class)->isFlushed() || !$cacheEnabled)
? null
: $cache->get($key);
if ($result) {
Expand Down
4 changes: 3 additions & 1 deletion src/Filters/RateLimitFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Kernel;

/**
* Provides rate limiting of execution of a callback
Expand Down Expand Up @@ -85,7 +87,7 @@ public function getContent($key, $callback)
{
// Bypass rate limiting if flushing, or timeout isn't set
$timeout = $this->config()->get('lock_timeout');
if (isset($_GET['flush']) || !$timeout) {
if (Injector::inst()->get(Kernel::class)->isFlushed() || !$timeout) {
return parent::getContent($key, $callback);
}

Expand Down

0 comments on commit 81d5c15

Please sign in to comment.