Skip to content

Commit

Permalink
minor #17396 [ClassLoader] Use symfony/polyfill-apcu (gapple)
Browse files Browse the repository at this point in the history
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        | -

#17358 updated ApcClassLoader to use polyfill-apcu, but not ApcUniversalClassLoader

2.7 / 2.8 tests are in LegacyApcUniversalClassLoaderTest

Commits
-------

a0dc399 [ClassLoader] Use symfony/polyfill-apcu
  • Loading branch information
fabpot committed Jan 25, 2016
2 parents 50b48f6 + a0dc399 commit 11257ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
Expand Up @@ -71,7 +71,7 @@ class ApcUniversalClassLoader extends UniversalClassLoader
*/
public function __construct($prefix)
{
if (!extension_loaded('apc')) {
if (!function_exists('apcu_fetch')) {
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
}

Expand All @@ -87,8 +87,8 @@ public function __construct($prefix)
*/
public function findFile($class)
{
if (false === $file = apc_fetch($this->prefix.$class)) {
apc_store($this->prefix.$class, $file = parent::findFile($class));
if (false === $file = apcu_fetch($this->prefix.$class)) {
apcu_store($this->prefix.$class, $file = parent::findFile($class));
}

return $file;
Expand Down
Expand Up @@ -13,15 +13,12 @@

use Symfony\Component\ClassLoader\ApcUniversalClassLoader;

/**
* @requires extension apc
*/
class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
apc_clear_cache('user');
apcu_clear_cache();
} else {
$this->markTestSkipped('APC is not enabled.');
}
Expand All @@ -30,7 +27,7 @@ protected function setUp()
protected function tearDown()
{
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
apc_clear_cache('user');
apcu_clear_cache();
}
}

Expand All @@ -39,7 +36,7 @@ public function testConstructor()
$loader = new ApcUniversalClassLoader('test.prefix.');
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');

$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apc_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apcu_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
}

/**
Expand Down

0 comments on commit 11257ee

Please sign in to comment.