#caching blade templates already evaluates code?

3 messages · Page 1 of 1 (latest)

viscid vessel
#

Hey - I asked the question in #general yesterday, but was unexpectedly called from my computer and can't easily find whether someone responded, so if you did: my apologies for missing and reposting...

I upgraded to L11 yesterday, which was a breeze, and works like a charm.
However - something I run into today which wasn't the case prior L11, is that my CI/CD pipeline to deploy to laravel Vapor is now broken.

As part of the process, we are running php artisan optimize before we upload the resources to vapor. This ensures that config, routes, but also view are being cached.
Now, since this runs on a github actions container, we don't have a database setup when that is being called, which was never an issue.

But now I'm getting an exception when the view are being compiled/cached:

The command "php artisan optimize" failed.  
Output:                                                                      
  ================                                                             

     INFO  Caching framework bootstrap, configuration, and metadata.           

    config ........................................................ 17.41ms DONE
    events ......................................................... 1.25ms DONE
    routes ........................................................ 22.64ms DONE
    views ......................................................... 13.52ms FAIL
                                                               
     Illuminate\Database\QueryException      

In the trace, I see it is trying to select some data from the database which I can link to this code in the blade templates:

<a href="{{ Tenancy::tenant()->url }}">

I'm a bit confused now: why would compiling/optimizing the views already execute/evaluate that piece of code in the template? Is this changed behaviour in L11?
When rolling back to L10, the issue is gone, so something must have changed - is anyone else running into similar issues?

tame bolt
#

AFAIK view cache doesn't execute views at all. The goal of view cache is to convert blade syntax to native PHP, so this will change {{ Tenancy::tenant()->url }} to <?php echo e(Tenancy::tenant()->url); ?>, it wouldn't execute that part (tried that locally). So likely there's something else going on, perhaps a service provider where you're executing a query (which you shouldn't do in a service provider).
Then again, difficult to tell without an error trace.

viscid vessel
#

THat's what I thought exactly, Robert. I just don't understand why upgrading to L11 introduces this issue and when I rollback to L10 I don't have the issue. And since it's only on github actions, it's very difficult to debug as I don't have a complete backtrace - I'll do some analysis.