Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] Accept only array in TagAwareAdapter::invalidateTags() #20172

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

Merged
merged 1 commit into from
Oct 9, 2016
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
5 changes: 1 addition & 4 deletions 5 src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ function ($deferred) {
/**
* {@inheritdoc}
*/
public function invalidateTags($tags)
public function invalidateTags(array $tags)
{
if (!is_array($tags)) {
$tags = array($tags);
}
foreach ($tags as $k => $tag) {
if ('' !== $tag && is_string($tag)) {
$tags[$k] = $tag.static::TAGS_PREFIX;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ interface TagAwareAdapterInterface extends AdapterInterface
/**
* Invalidates cached items using tags.
*
* @param string|string[] $tags A tag or an array of tags to invalidate
* @param string[] $tags An array of tags to invalidate
*
* @return bool True on success
*
* @throws InvalidArgumentException When $tags is not valid
*/
public function invalidateTags($tags);
public function invalidateTags(array $tags);
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public function testInvalidateTags()
$pool->save($i3->tag('foo')->tag('baz'));
$pool->save($foo);

$pool->invalidateTags('bar');
$pool->invalidateTags(array('bar'));

$this->assertFalse($pool->getItem('i0')->isHit());
$this->assertTrue($pool->getItem('i1')->isHit());
$this->assertFalse($pool->getItem('i2')->isHit());
$this->assertTrue($pool->getItem('i3')->isHit());
$this->assertTrue($pool->getItem('foo')->isHit());

$pool->invalidateTags('foo');
$pool->invalidateTags(array('foo'));

$this->assertFalse($pool->getItem('i1')->isHit());
$this->assertFalse($pool->getItem('i3')->isHit());
Expand All @@ -80,7 +80,7 @@ public function testTagsAreCleanedOnSave()
$i = $pool->getItem('k');
$pool->save($i->tag('bar'));

$pool->invalidateTags('foo');
$pool->invalidateTags(array('foo'));
$this->assertTrue($pool->getItem('k')->isHit());
}

Expand All @@ -93,7 +93,7 @@ public function testTagsAreCleanedOnDelete()
$pool->deleteItem('k');

$pool->save($pool->getItem('k'));
$pool->invalidateTags('foo');
$pool->invalidateTags(array('foo'));

$this->assertTrue($pool->getItem('k')->isHit());
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.