Upgrading Acorn from 2.x to 5.x

The process is very well written in documentation https://roots.io/acorn/docs/upgrading-acorn/.

All went smooth until deploying to staging. I saw this error after deployment:

Fatal error: Uncaught Exception: syntax error, unexpected end of file, expecting "elseif" or "else" or "endif" (View: /web/app/themes/my-theme/resources/views/partials/schema-organization.blade.php) (View: /web/app/themes/my-theme/resources/views/partials/schema-organization.blade.php)
in /web/app/cache/acorn/framework/views/fed5a4d452a34780f62e57164782d221.php on line 19

But the question for me was why I have not experienced issue on my localhost. Because I updated only composer dependencies and functions.php, the was no reason to refresh the views automatically. All I need to do to replicate the issue was to run command:

wp acorn optimize:clear

Part of our schema-organization.blade.php file:

 "@context": "https://schema.org",
 "@type": "AggregateRating",

The problematic was the @context. I’m not sure in which version of blade, but there was introduced a new directive @context. It expects a closing directive.

The solution was to use the esccape a Blade directive with double @@:

"@@context": "https://schema.org",
"@@type": "AggregateRating",

As you can see I escaped also type. IMO it’s a good practise to escape non directives like this one in the future.

Dawid Avatar