Skip to content

Visiting a URL ending with an asterisk will throw error #242

@jasonvarga

Description

@jasonvarga

Visiting /* will throw an exception.

The error comes from line 46 here:

Statamic\Eloquent\Taxonomies\Taxonomy::fromModel(): Argument #1 ($model) must be of type Illuminate\Database\Eloquent\Model, array given

public function findByHandle($handle): ?TaxonomyContract
{
$taxonomyModel = Blink::once("eloquent-taxonomies-{$handle}", function () use ($handle) {
return app('statamic.eloquent.taxonomies.model')::whereHandle($handle)->first();
});
return $taxonomyModel ? app(TaxonomyContract::class)->fromModel($taxonomyModel) : null;
}

This is because when you provide a key ending with * to Blink, it returns an array of values.

$blink->get('key'); // Returns 'value'
$blink->get('prefix*'); // Returns an array of values whose keys start with 'prefix'

Maybe line 46 should be changed to

return $taxonomyModel instanceof Model ? ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions