Skip to content

Fix the Varnish purger #1156

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
Jun 2, 2017
Merged

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Jun 2, 2017

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a
  • Allows non indexed arrays
  • Use request instead of requestAsync to throw an error in the purge doesn't work

@@ -48,10 +48,10 @@ public function purge(array $iris)
return sprintf('(^|\,)%s($|\,)', preg_quote($iri));
}, $iris);

$regex = isset($parts[1]) ? sprintf('(%s)', implode(')|(', $parts)) : $parts[0];
$regex = count($parts) > 1 ? sprintf('(%s)', implode(')|(', $parts)) : array_shift($parts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isset may still work with array shift no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because the array has the following format: ['/foo' => '/foo', '/bar' => '/bar']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:| nice way to avoid counting otherwise.

Copy link
Member

@soyuka soyuka Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current might work, not sure about the perf reward though. array_shift does put cursor in position 0 every call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perf are better with current() (or array_pop() for example). But I prefer reset(), it's more safe.

@dunglas dunglas merged commit 4275dc9 into api-platform:master Jun 2, 2017
@dunglas dunglas deleted the fix_varnish_purger branch June 2, 2017 21:54
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants