Skip to content

buildRouteCollection() may fail if wrong value is already present in cache #4

Description

@bancer
    protected function buildRouteCollection(): RouteCollection
    {
    ...
                return Cache::remember(static::ROUTE_COLLECTION_CACHE_KEY, function () {
                    return $this->prepareRouteCollection();
                }, $this->cacheConfig);

This fails with PHP type error if the cache contains for example false value. Probably should be something like this:

                $cached = Cache::remember(static::ROUTE_COLLECTION_CACHE_KEY, function () {
                    return $this->prepareRouteCollection();
                }, $this->cacheConfig);
                if ($cached instance of RouteCollection) {
                    return $cached;
                } else {
                    Cache::delete(static::ROUTE_COLLECTION_CACHE_KEY, $this->cacheConfig);
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions