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

Strip directory separators from auto-generated cell cache name. Fixes… #2851

Merged
merged 1 commit into from
Apr 20, 2020
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 system/View/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ public function render(string $library, $params = null, int $ttl = 0, string $ca
list($class, $method) = $this->determineClass($library);

// Is it cached?
$cacheName = ! empty($cacheName) ? $cacheName : $class . $method . md5(serialize($params));
$cacheName = ! empty($cacheName)
? $cacheName
: str_replace(['\\', '/'], '', $class) . $method . md5(serialize($params));

if (! empty($this->cache) && $output = $this->cache->get($cacheName))
{
Expand Down
15 changes: 15 additions & 0 deletions tests/system/View/CellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ public function testRenderCached()
$this->assertEquals(implode(',', $expected), $this->cell->render('\Tests\Support\View\SampleClass::echobox', $params, 1, 'rememberme'));
}

public function testRenderCachedAutoName()
{
$params = 'one=two,three=four';
$expected = [
'one' => 'two',
'three' => 'four',
];

$this->assertEquals(implode(',', $expected), $this->cell->render('\Tests\Support\View\SampleClass::echobox', $params, 60));
$params = 'one=six,three=five';
// When auto-generating it takes the params as part of cachename, so it wouldn't have actually cached this, but
// we want to make sure it doesn't throw us a curveball here.
$this->assertEquals('six,five', $this->cell->render('\Tests\Support\View\SampleClass::echobox', $params, 1));
}

//--------------------------------------------------------------------

public function testParametersMatch()
Expand Down