8000 BUGFIX check for apc.enable_cli if PHP_SAPI==cli by andrewandante · Pull Request #25080 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

BUGFIX check for apc.enable_cli if PHP_SAPI==cli #25080

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

Closed

Conversation

andrewandante
Copy link
@andrewandante andrewandante commented Nov 21, 2017
Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? TODO
License MIT

Experienced an issue when running PHPUnit via CLI on my application. A slew of errors like:

[2017-11-21 11:50:15] manifestcache-log.WARNING: Failed to save values {"keys":["ErrorPageErrorFormatter_php_6bac9d263304c06cb35951dcecaa888d"],"exception":null} []

Issue was that I was missing apc.enable_cli=1 in my apcu.ini - however, APCU was still being detected as isSupported() because the check wasn't taking into account that I was running via CLI. This PR checks based on PHP_SAPI.

TODO

  • Ensure tests pass

@@ -23,7 +23,13 @@
{
public static function isSupported()
{
return function_exists('apcu_fetch') && ini_get('apc.enabled');
if ('cli' === PHP_SAPI) {
Copy link
Contributor

Choose a reason for hiding this comment

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

return function_exists('apcu_fetch') && ini_get('cli' === PHP_SAPI ? 'apc.enable_cli' : 'apc.enabled');

Copy link
Author

Choose a reason for hiding this comment

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

Ta, updated :)

@andrewandante andrewandante force-pushed the bugfix/check_apc.enable_cli branch from e0c5155 to 40e415a Compare November 21, 2017 13:09
@nicolas-grekas
Copy link
Member
nicolas-grekas commented Nov 21, 2017

This breaks cache warmups: APCu should be considered as supported when the cache is warmed up on the command line, which is what the current logic provides.

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Nov 21, 2017
@andrewandante
Copy link
Author

It seems then that this needs to be able to handle that as an exception - maybe we can do something along the lines of:

public static function isSupported($checkCLI = true) {...}

Or the check on cache warmup should be explicitly checking for ini_get('apc.enabled'). What do you think?

@nicolas-grekas
Copy link
Member
nicolas-grekas commented Nov 21, 2017

RIght now, I'd think you should to the apc.enable_cli check :)

@andrewandante
Copy link
Author

Sure - have patched at the SilverStripe level. Would you consider a Warning being thrown, rather than returning false explicitly?

@nicolas-grekas
Copy link
Member

I think the warning is already thrown if you provide a logger.
Returning false is required per PSR-6.

@nicolas-grekas
Copy link
Member

@andrewandante are you using the ApcuAdapter directly, or do you use it through the default configuration? If via default, I'm wondering if we could/should patch the ChainAdapter to return true when the last adapter succeeds, no matter the other ones.

@andrewandante
Copy link
Author

We are calling it directly - see here: https://github.com/andrewandante/silverstripe-framework/blob/master/src/Core/Cache/DefaultCacheFactory.php#L87

Not sure how that affects your decision on ChainAdapter :)

@nicolas-grekas
Copy link
Member

Not sure how that affects your decision on ChainAdapter :)

neither am I :)
I think we can close this PR, as explained. OK for you?

@andrewandante
Copy link
Author

Sure thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0