diff --git a/core/lib/Drupal/Core/PhpStorage/CacheStorage.php b/core/lib/Drupal/Core/PhpStorage/CacheStorage.php index daf2cfb..ccd38dc 100644 --- a/core/lib/Drupal/Core/PhpStorage/CacheStorage.php +++ b/core/lib/Drupal/Core/PhpStorage/CacheStorage.php @@ -72,7 +72,6 @@ public function load($name) { stream_wrapper_register('phar', 'Drupal\Core\StreamWrapper\StreamWrapperForCacheStorage'); StreamWrapperForCacheStorage::init($this, $cached->data); $return = (include "phar://$name") !== FALSE; - #var_dump(opcache_get_status(TRUE)['scripts']["phar://$name"]); // Restore the system wrapper. stream_wrapper_restore('phar'); return $return; diff --git a/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php b/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php index 4b3cb8d..69598e1 100644 --- a/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php +++ b/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php @@ -48,9 +48,6 @@ static function get($name) { ); } $class = isset($configuration['class']) ? $configuration['class'] : 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage'; - if ($name == 'service_container') { - $class = 'Drupal\Core\PhpStorage\CacheStorage'; - } if (!isset($configuration['bin'])) { $configuration['bin'] = $name; } diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php index 53492d8..e259be5 100644 --- a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php +++ b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\Component\PhpStorage; +use Drupal\Component\PhpStorage\PhpStorageInterface; use Drupal\Tests\UnitTestCase; use org\bovigo\vfs\vfsStream; @@ -34,7 +35,7 @@ protected function setUp() { /** * Assert that a PHP storage's load/save/delete operations work. */ - public function assertCRUD($php) { + public function assertCRUD(PhpStorageInterface $php) { $name = $this->randomMachineName() . '/' . $this->randomMachineName() . '.php'; // Find a global that doesn't exist. @@ -48,6 +49,7 @@ public function assertCRUD($php) { $this->assertTrue($success, 'Saved php file'); $php->load($name); $this->assertTrue($GLOBALS[$random], 'File saved correctly with correct value'); + $this->additionalAssertCRUD($php, $name); // If the file was successfully loaded, it must also exist, but ensure the // exists() method returns that correctly. @@ -62,4 +64,15 @@ public function assertCRUD($php) { $this->assertFalse($php->delete($name), 'Delete fails on missing file'); } + /** + * Additional asserts to be run. + * + * @param \Drupal\Component\PhpStorage\PhpStorageInterface $php + * The PHP storage object. + * @param string $name + * The name of an object. It should exist in the storage. + */ + protected function additionalAssertCRUD(PhpStorageInterface $php, $name) { + + } } diff --git a/core/tests/Drupal/Tests/Core/PhpStorage/CacheStorageTest.php b/core/tests/Drupal/Tests/Core/PhpStorage/CacheStorageTest.php index da5a272..7e9223c 100644 --- a/core/tests/Drupal/Tests/Core/PhpStorage/CacheStorageTest.php +++ b/core/tests/Drupal/Tests/Core/PhpStorage/CacheStorageTest.php @@ -7,9 +7,9 @@ namespace Drupal\Tests\Core\PhpStorage; +use Drupal\Component\PhpStorage\PhpStorageInterface; use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\PhpStorage\CacheStorage; -use Drupal\Core\Site\Settings; use Drupal\Tests\Component\PhpStorage\PhpStorageTestBase; /** @@ -31,10 +31,21 @@ public function testCRUD() { $secret = $this->randomMachineName(); $storage = new CacheStorage([ 'secret' => $secret, - 'cache_backend_factory' => function (array $configuration) { return new MemoryBackend($configuration['bin']);}, + 'cache_backend_factory' => function (array $configuration) { + return new MemoryBackend($configuration['bin']); + }, 'bin' => 'test' ]); $this->assertCRUD($storage); } + /** + * {@inheritdoc} + */ + protected function additionalAssertCRUD(PhpStorageInterface $php, $name) { + $this->assertEquals(opcache_get_status(TRUE)['scripts']["phar://$name"]['hits'], 0); + $php->load($name); + $this->assertEquals(opcache_get_status(TRUE)['scripts']["phar://$name"]['hits'], 1); + } + }