Skip to content

Commit eaef88c

Browse files
committed
bug symfony#17358 [ClassLoader] Use symfony/polyfill-apcu (nicolas-grekas)
This PR was merged into the 2.3 branch. Discussion ---------- [ClassLoader] Use symfony/polyfill-apcu | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Fixes APC usage on PHP 7 or when APCu bc-layer is disabled Commits ------- 623595f [ClassLoader] Use symfony/polyfill-apcu
2 parents 36df0a7 + 623595f commit eaef88c

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ before_install:
3838
- echo session.gc_probability = 0 >> $INI_FILE
3939
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi;
4040
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then echo extension = memcache.so >> $INI_FILE; fi;
41-
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.10 && echo apc.enable_cli = 1 >> $INI_FILE) || echo "Let's continue without apcu extension"; fi;
42-
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then pecl install -f memcached-2.1.0 || echo "Let's continue without memcached extension"; fi;
41+
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.10 && echo apc.enable_cli = 1 >> $INI_FILE); fi;
42+
- if [[ $TRAVIS_PHP_VERSION = 7.* ]]; then (echo yes | pecl install -f apcu-5.1.2 && echo apc.enable_cli = 1 >> $INI_FILE); fi;
43+
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then pecl install -f memcached-2.1.0; fi;
4344
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi;
4445
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi;
4546
- if [[ $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer-auth.json ~/.composer/auth.json; fi;

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"php": ">=5.3.3",
2020
"doctrine/common": "~2.4",
2121
"paragonie/random_compat": "~1.0",
22+
"symfony/polyfill-apcu": "~1.0,>=1.0.2",
2223
"twig/twig": "~1.23|~2.0",
2324
"psr/log": "~1.0"
2425
},

src/Symfony/Component/ClassLoader/ApcClassLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class ApcClassLoader
6767
*/
6868
public function __construct($prefix, $decorated)
6969
{
70-
if (!extension_loaded('apc')) {
71-
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not enabled.');
70+
if (!function_exists('apcu_fetch')) {
71+
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not installed.');
7272
}
7373

7474
if (!method_exists($decorated, 'findFile')) {
@@ -122,8 +122,8 @@ public function loadClass($class)
122122
*/
123123
public function findFile($class)
124124
{
125-
if (false === $file = apc_fetch($this->prefix.$class)) {
126-
apc_store($this->prefix.$class, $file = $this->decorated->findFile($class));
125+
if (false === $file = apcu_fetch($this->prefix.$class)) {
126+
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class));
127127
}
128128

129129
return $file;

src/Symfony/Component/ClassLoader/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"minimum-stability": "dev",
1919
"require": {
20-
"php": ">=5.3.3"
20+
"php": ">=5.3.3",
21+
"symfony/polyfill-apcu": "~1.0,>=1.0.2"
2122
},
2223
"require-dev": {
2324
"symfony/finder": "~2.0,>=2.0.5"

0 commit comments

Comments
 (0)