Merge branch '2.3' into 2.7
* 2.3: [ClassLoader] Use symfony/polyfill-apcu
This commit is contained in:
commit
778e4f6302
@ -76,7 +76,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.');
|
||||
}
|
||||
|
||||
@ -92,8 +92,8 @@ class ApcUniversalClassLoader extends UniversalClassLoader
|
||||
*/
|
||||
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;
|
||||
|
@ -15,14 +15,13 @@ use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @requires extension apc
|
||||
*/
|
||||
class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
apc_clear_cache('user');
|
||||
apcu_clear_cache('user');
|
||||
} else {
|
||||
$this->markTestSkipped('APC is not enabled.');
|
||||
}
|
||||
@ -31,7 +30,7 @@ class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
protected function tearDown()
|
||||
{
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
apc_clear_cache('user');
|
||||
apcu_clear_cache('user');
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +39,7 @@ class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$loader = new ApcUniversalClassLoader('test.prefix.');
|
||||
$loader->registerNamespace('LegacyApc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
|
||||
$this->assertEquals($loader->findFile('\LegacyApc\Namespaced\FooBar'), apc_fetch('test.prefix.\LegacyApc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
|
||||
$this->assertEquals($loader->findFile('\LegacyApc\Namespaced\FooBar'), apcu_fetch('test.prefix.\LegacyApc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user