Skip to content

Caching bassetArchive / bassetDirectory doesn't work #154

@jorrit

Description

@jorrit

I try to cache a project where backpack/tinymce-field is installed. This is part of the output:

php artisan basset:cache -v -v -v

....
 55 C:\Projects\Other\cca-roadbookgenerator\vendor/backpack/theme-tabler/resources/assets/css/style.css
    Not in a CDN or local filesystem, falling back to provided path
....

This message is shown because this code in BassetCache.php gives an exception, which is caught and swallowed:

            try {
                $result = $basset->{$type}(...$args)->value;
            } catch (Throwable $th) {
                $result = StatusEnum::INVALID->value;
            }

The exception message is:

Call to undefined method Backpack\Basset\BassetManager::@basset()

This is caused by the fact that the @ matched by this regular expression is never stripped off:

preg_match_all('/(basset|@bassetArchive|@bassetDirectory)\((.+)\)/', $content, $matches);

For some reason, the asset tag is not matched with a @, so it works. bassetArchive and bassetDirectory are matched with the @ and do not work.
This was broken in 26170fc.

I suggest manually stripping the @, becaus

return collect($matches[1])->map(fn (string $type, int $i) => [ltrim($type, '@'), $matches[2][$i]]);

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