diff --git a/core/lib/Drupal/Core/PhpStorage/CacheStorage.php b/core/lib/Drupal/Core/PhpStorage/CacheStorage.php index 872f9da..daf2cfb 100644 --- a/core/lib/Drupal/Core/PhpStorage/CacheStorage.php +++ b/core/lib/Drupal/Core/PhpStorage/CacheStorage.php @@ -11,7 +11,7 @@ use Drupal\Core\Cache\DatabaseBackend; use Drupal\Core\Cache\DatabaseCacheTagsChecksum; use Drupal\Core\Database\Database; -use Drupal\Core\StreamWrapper\SpecialInMemoryStream; +use Drupal\Core\StreamWrapper\StreamWrapperForCacheStorage; /** * This class stores PHP classes in a cache storage keeping it opcacheable. @@ -69,8 +69,8 @@ public function load($name) { // multiple times by the classloader as the container class is loaded. // So for better performance use the phar protocol. stream_wrapper_unregister('phar'); - stream_wrapper_register('phar', 'Drupal\Core\StreamWrapper\SpecialInMemoryStream'); - SpecialInMemoryStream::init($this, $cached->data); + 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. @@ -162,7 +162,7 @@ public function listAll() { */ protected function cacheBackend() { if (!isset($this->cacheBackend)) { - if (isset($this->configuration['cache_backend_factory']) && is_callable($this->configuration['cache_backend_factory'])) { + if (isset($this->configuration['cache_backend_factory'])) { $this->cacheBackend = call_user_func($this->configuration['cache_backend_factory'], $this->configuration); } else { diff --git a/core/lib/Drupal/Core/StreamWrapper/SpecialInMemoryStream.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperForCacheStorage.php similarity index 51% rename from core/lib/Drupal/Core/StreamWrapper/SpecialInMemoryStream.php rename to core/lib/Drupal/Core/StreamWrapper/StreamWrapperForCacheStorage.php index a69bc10..6ef53d0 100644 --- a/core/lib/Drupal/Core/StreamWrapper/SpecialInMemoryStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperForCacheStorage.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\StreamWrapper\SpecialInMemoryStream. + * Contains \Drupal\Core\StreamWrapper\StreamWrapperForCacheStorage. */ namespace Drupal\Core\StreamWrapper; @@ -11,9 +11,11 @@ /** * The stream wrapper for \Drupal\Core\PhpStorage\CacheStorage . * - * This class is not usable as a generic stream wrapper. + * This class is not usable as a generic stream wrapper, it is specifically + * written to work with \Drupal\Core\PhpStorage\CacheStorage and allows us + * to manually set the mtime of the "file" the stream is wrapping. */ -class SpecialInMemoryStream { +class StreamWrapperForCacheStorage { /** * @var \Drupal\Core\PhpStorage\CacheStorage @@ -53,38 +55,6 @@ public static function init(CacheStorage $storage, $mtime) { static::$mtime = $mtime; } - public function dir_closedir() { - throw new \BadMethodCallException('Not implemented'); - } - - public function dir_opendir($path) { - throw new \BadMethodCallException('Not implemented'); - } - - public function dir_readdir() { - throw new \BadMethodCallException('Not implemented'); - } - - public function dir_rewinddir() { - throw new \BadMethodCallException('Not implemented'); - } - - public function mkdir() { - throw new \BadMethodCallException('Not implemented'); - } - - public function rename() { - throw new \BadMethodCallException('Not implemented'); - } - - public function rmdir() { - throw new \BadMethodCallException('Not implemented'); - } - - public function stream_cast() { - return static::$handle ? static::$handle : FALSE; - } - public function stream_close () { return fclose(static::$handle); } @@ -97,14 +67,6 @@ public function stream_flush() { return fflush(static::$handle); } - public function stream_lock($operation) { - return flock(static::$handle, $operation); - } - - public function stream_metadata() { - throw new \BadMethodCallException('Not implemented'); - } - public function stream_open($path) { static::$handle = static::$storage->open($path); return (bool) static::$handle; @@ -114,34 +76,10 @@ public function stream_read($count) { return fread(static::$handle, $count); } - public function stream_seek($offset, $whence = SEEK_SET) { - return fseek(static::$handle, $offset, $whence); - } - - public function stream_set_option() { - throw new \BadMethodCallException('Not implemented'); - } - public function stream_stat() { return fstat(static::$handle); } - public function stream_tell() { - return ftell(static::$handle); - } - - public function stream_truncate() { - throw new \BadMethodCallException('Not implemented'); - } - - public function stream_write() { - throw new \BadMethodCallException('Not implemented'); - } - - public function unlink() { - throw new \BadMethodCallException('Not implemented'); - } - public function url_stat() { $return = [ 'dev' => 0,