Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ClassLoader] Use symfony/polyfill-apcu #17396

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
Jan 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@

use Symfony\Component\ClassLoader\ApcUniversalClassLoader;

/**
* @requires extension apc
*/
class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
Copy link
Contributor

Choose a reason for hiding this comment

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

@nicolas-grekas I think you missed to remove that in https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php#L18 as this will forbid to use this test against apcu without bc layer.

Copy link
Contributor

Choose a reason for hiding this comment

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

and its already skipped in setUp anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

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