putyourlightson / craft-blitz

Intelligent static page caching for creating lightning-fast sites with Craft CMS.
https://putyourlightson.com/plugins/blitz
Other
149 stars 36 forks source link

Error with properties after updating to v5 createGzipFiles/createBrotliFile #668

Closed loqus closed 4 months ago

loqus commented 4 months ago

Bug Report

After updating to Craft 5 Pro and updating Blitz to ^5.3 I got a non-functioning dashboard and non functioning blitz plugin page. It seems to be related to the 2 properties that got removed in v5.0.0

Setting unknown property: putyourlightson\blitz\drivers\storage\FileStorage::createGzipFiles Setting unknown property: putyourlightson\blitz\drivers\storage\FileStorage::createBrotliFile

After manually adding the properties from v4 back into the FileStorage everything was functioning again. I don't have these values active in the blitz.php config and I am unsure where they are called from.

Diagnostics Report

PHP version | 8.2.19 Craft edition & version | Craft Pro 5.1.5 Blitz | 5.3.1

bencroker commented 4 months ago

Can you share the “Blitz Plugin Settings” part of the diagnostics report, so I can see what settings you have?

loqus commented 4 months ago

Well good news, after uninstalling and re-installing the plugin, the errors above are gone. But now a new one pops up:

I cannot load the generate report page. I cleared the runtime directory. But clicking on the generate diagnostics report gives me a (TypeError(code: 0): get_class(): Argument #1 ($object) must be of type object, string given at /var/www/vhosts/xxx/xxx/storage/runtime/compiled_templates/cd/cdbcdf1d50c468a38bece6c6b7579c04.php:88 (which is the blitz/_utilities/diagnostics/_includes/report template)

Row 88: echo twig_escape_filter($this->env, get_class($context["module"]), "html", null, true);

PS i have the same error on another Craft CMS (different site) running on Craft Pro 4.9.2, Blitz 4.18.0, PHP 8.1.28

bencroker commented 4 months ago

That’s good to hear!

Can you please share the entire stack trace of the error so I can track it down? The error appears to be referencing a custom module.

bencroker commented 4 months ago

Any update on this, @loqus?

loqus commented 4 months ago

This is what I got now

Twig\Error\RuntimeError: Impossible to access an attribute ("id") on a string variable ("modules\Module"). in /var/www/vhosts/example.com/httpdocs/vendor/putyourlightson/craft-blitz/src/templates/_utilities/diagnostics/_includes/report.twig:19 Stack trace:

0 /var/www/vhosts/example.com/httpdocs/vendor/craftcms/cms/src/helpers/Template.php(141): twig_get_attribute()

1 /var/www/vhosts/example.com/httpdocs/storage/runtime/compiled_templates/93/9398d210647b70fc0167005b4d55291e.php(86): craft\helpers\Template::attribute()

2 /var/www/vhosts/example.com/httpdocs/vendor/twig/twig/src/Template.php(394): __TwigTemplate_ace9722dce9fa9f6353fa7ca127362d3->doDisplay()

3 /var/www/vhosts/example.com/httpdocs/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()

4 /var/www/vhosts/example.com/httpdocs/vendor/twig/twig/src/Template.php(379): Twig\Template->display()

5 /var/www/vhosts/example.com/httpdocs/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render()

6 /var/www/vhosts/example.com/httpdocs/vendor/twig/twig/src/Environment.php(280): Twig\TemplateWrapper->render()

7 /var/www/vhosts/example.com/httpdocs/vendor/craftcms/cms/src/web/View.php(482): Twig\Environment->render()

8 /var/www/vhosts/example.com/httpdocs/vendor/putyourlightson/craft-blitz/src/controllers/DiagnosticsController.php(144): craft\web\View->renderTemplate()

9 /var/www/vhosts/example.com/httpdocs/vendor/putyourlightson/craft-blitz/src/controllers/DiagnosticsController.php(50): putyourlightson\blitz\controllers\DiagnosticsController->getReport()

10 [internal function]: putyourlightson\blitz\controllers\DiagnosticsController->actionReport()

11 /var/www/vhosts/example.com/httpdocs/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()

12 /var/www/vhosts/example.com/httpdocs/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()

13 /var/www/vhosts/example.com/httpdocs/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()

14 /var/www/vhosts/example.com/httpdocs/vendor/craftcms/cms/src/web/Application.php(340): yii\base\Module->runAction()

15 /var/www/vhosts/example.com/httpdocs/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction()

16 /var/www/vhosts/example.com/httpdocs/vendor/craftcms/cms/src/web/Application.php(308): yii\web\Application->handleRequest()

17 /var/www/vhosts/example.com/httpdocs/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()

18 /var/www/vhosts/example.com/httpdocs/web/index.php(228): yii\base\Application->run()

19 {main}

bencroker commented 4 months ago

It’s unclear why modules\Module is a string and not a module. Can you please show me the modules section in your config/app.php file?

loqus commented 4 months ago

Might it be the 'my-module' => \modules\Module::class, default module in there? It's never changed since using Craft since v2 OMG, yes it is.

bencroker commented 4 months ago

It looks like the module not being bootstrapped was causing the issue. Fixed in https://github.com/putyourlightson/craft-blitz/commit/64af11ee7701bab3d2435323f4577bb91d53737d to only show bootstrapped modules, for the next release. Thanks for helping me figure this out!

bencroker commented 3 months ago

Released in 4.18.2 and 5.3.2.

sarahschuetz commented 2 months ago

@bencroker running in the same initial error when updating to Craft 5 and Blitz 5.4 ⚡️ Uninstalling and re-installing fixed the error for me, too.

bencroker commented 2 months ago

Thanks @sarahschuetz, https://github.com/putyourlightson/craft-blitz/commit/b2b21384f01eb98c6cd79129a749de06c67d880d should fix that in future.

bencroker commented 2 months ago

Released in 5.5.0.