Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Do not rely on flush variable #122

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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