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

Don’t compile when Opcache is not enabled on CLI #20883

Closed
wants to merge 2 commits into
base: 3.2
from

Conversation

Projects
None yet
6 participants
@ruudk
Contributor

ruudk commented Dec 12, 2016

Q A
Branch? 3.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #20878
License MIT

This should fix #20878 "Zend OPcache seems to be disabled, can't compile file" when Opcache is enabled, but opcache.enable_cli is turned off.

@@ -109,15 +109,28 @@ protected function doSave(array $values, $lifetime)
$value = serialize($value);
}
} elseif (!is_scalar($value)) {
throw new InvalidArgumentException(sprintf('Value of type "%s" is not serializable', $key, gettype($value)));
throw new InvalidArgumentException(sprintf('Value of type "%s" is not serializable', gettype($value)));

This comment has been minimized.

@nicolas-grekas

nicolas-grekas Dec 12, 2016

Member

Borrowed from PhpArrayAdapter:
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, gettype($value)));

This comment has been minimized.

@ruudk

ruudk Dec 13, 2016

Contributor

Fixed

*/
private function compileFile($file)
{
if ('cli' === php_sapi_name() && !ini_get('opcache.enable_cli')) {

This comment has been minimized.

@nicolas-grekas

nicolas-grekas Dec 12, 2016

Member

Use PHP_SAPI constant instead

This comment has been minimized.

@ruudk

ruudk Dec 13, 2016

Contributor

Fixed

/**
* @param string $file
*/
private function compileFile($file)

This comment has been minimized.

@nicolas-grekas

nicolas-grekas Dec 12, 2016

Member

Not sure the extra method is worth it.

This comment has been minimized.

@ruudk

ruudk Dec 13, 2016

Contributor

Ok, removed it.

*/
private function compileFile($file)
{
if ('cli' === php_sapi_name() && !ini_get('opcache.enable_cli')) {

This comment has been minimized.

@sstok

sstok Dec 13, 2016

Contributor

This can be changed to an or-case with the @opcache_compile_file($file);

if ('cli' === PHP_SAPI || !ini_get('opcache.enable_cli')) {
    @opcache_compile_file($file);
}

This comment has been minimized.

@ruudk

ruudk Dec 13, 2016

Contributor

I just typed these lines, haha :)

@javiereguiluz javiereguiluz added the Cache label Dec 13, 2016

@fabpot

This comment has been minimized.

Member

fabpot commented Dec 13, 2016

Thank you @ruudk.

fabpot added a commit that referenced this pull request Dec 13, 2016

bug #20883 Don’t compile when Opcache is not enabled on CLI (ruudk)
This PR was squashed before being merged into the 3.2 branch (closes #20883).

Discussion
----------

Don’t compile when Opcache is not enabled on CLI

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20878
| License       | MIT

This should fix #20878 "Zend OPcache seems to be disabled, can't compile file" when Opcache is enabled, but `opcache.enable_cli` is turned off.

Commits
-------

5222643 Don’t compile when Opcache is not enabled on CLI

@fabpot fabpot closed this Dec 13, 2016

@fabpot fabpot referenced this pull request Dec 13, 2016

Merged

Release v3.2.1 #20897

@nicolas-grekas

This comment has been minimized.

Member

nicolas-grekas commented Dec 13, 2016

@ruudk ruudk deleted the ruudk:fix-opcache-cli branch Dec 13, 2016

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