diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 0032fdcb7..1f2c4dc5f 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -10,7 +10,6 @@ namespace Grav\Common; use DirectoryIterator; -use Doctrine\Common\Cache\Cache as DoctrineCache; use Doctrine\Common\Cache\CacheProvider; use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Exception; @@ -332,7 +331,7 @@ class Cache extends Getters * If there is no config option for $driver in the config, or it's set to 'auto', it will * pick the best option based on which cache extensions are installed. * - * @return DoctrineCache The cache driver to use + * @return CacheProvider The cache driver to use */ public function getCacheDriver(AdapterInterface $adapter = null) { @@ -340,7 +339,12 @@ class Cache extends Getters $adapter = $this->getCacheAdapter(); } - return DoctrineProvider::wrap($adapter); + $cache = DoctrineProvider::wrap($adapter); + if (!$cache instanceof CacheProvider) { + throw new \RuntimeException('Internal error'); + } + + return $cache; } /** diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php index f3978bc1d..b0b2c38b8 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php +++ b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php @@ -57,7 +57,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface public const ORDER_LIST_REGEX = '/(\/\d+)\.[^\/]+/u'; public const PAGE_ROUTE_REGEX = '/\/\d+\./u'; - /** @var PageObject|array */ + /** @var T|array */ protected $_root; /** @var array|null */ protected $_params; diff --git a/system/src/Grav/Common/Flex/Types/Users/UserObject.php b/system/src/Grav/Common/Flex/Types/Users/UserObject.php index d9217917d..751ceb41e 100644 --- a/system/src/Grav/Common/Flex/Types/Users/UserObject.php +++ b/system/src/Grav/Common/Flex/Types/Users/UserObject.php @@ -87,9 +87,9 @@ class UserObject extends FlexObject implements UserInterface, Countable protected $_uploads_original; /** @var FileInterface|null */ protected $_storage; - /** @var UserGroupIndex */ + /** @var UserGroupIndex|null */ protected $_groups; - /** @var Access */ + /** @var Access|null */ protected $_access; /** @var array|null */ protected $access; diff --git a/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php b/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php index 493ab4398..d73173683 100644 --- a/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php +++ b/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php @@ -46,7 +46,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S * Add a single page to a collection * * @param PageInterface $page - * @return $this + * @return $this|PageCollectionInterface */ public function addPage(PageInterface $page); @@ -63,7 +63,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S * * Create a copy of this collection * - * @return static + * @return static */ public function copy(); diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index ec48b5173..36289e64d 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -753,6 +753,10 @@ class Pages break; } + if (!$collection instanceof Collection) { + $collection = new Collection($collection->toArray()); + } + return $collection; } diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php index 472a5ffa8..c83ed8363 100644 --- a/system/src/Grav/Framework/Flex/FlexDirectory.php +++ b/system/src/Grav/Framework/Flex/FlexDirectory.php @@ -415,6 +415,7 @@ class FlexDirectory implements FlexDirectoryInterface $config = $this->getConfig('object.cache.' . $namespace); if (empty($config['enabled'])) { $cache = new MemoryCache('flex-objects-' . $this->getFlexType()); + $cache->setValidation(false); } else { $lifetime = $config['lifetime'] ?? 60; @@ -431,10 +432,9 @@ class FlexDirectory implements FlexDirectoryInterface $debugger->addException($e); $cache = new MemoryCache('flex-objects-' . $this->getFlexType()); + $cache->setValidation(false); } - // Disable cache key validation. - $cache->setValidation(false); $this->cache[$namespace] = $cache; }