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

Issue with Blitz after updating to Craft CMS 4.9.0 #584

Closed diegocosta-dev closed 10 months ago

diegocosta-dev commented 10 months ago

Problem Description: After updating to Blitz version 4.9.0, I am encountering an issue with Blitz. When attempting certain operations, the following error is generated:

image

Can anyone help me with this?

Context:

Queue Configuration (app.php):


return [
    'id' => App::env('CRAFT_APP_ID') ?: 'CraftCMS',
    'components' => [
        'queue' => [
            'ttr' => 600,
        ],
    ],
];
bencroker commented 10 months ago

Thanks for reporting this, I’ll work on a fix. In the meantime, commenting out the queue component in app.php should prevent the error, as a short-term solution.

bencroker commented 10 months ago

I cannot reproduce the issue locally. What operations are triggering this exception, and can you please share the full stack trace?

diegocosta-dev commented 10 months ago

Thank you for looking into the issue.

Operations Triggering Exception: The exception appears to occur when trying to save an entry like the home page.

image

or when trying to regenerate it manually.

image image

Composer (composer.json):

{
  "require": {
    "aodihis/video-utils": "2.0.2",
    "carlcs/craft-redactorcustomstyles": "4.0.3",
    "carlcs/craft-uielementfields": "2.0.3",
    "craftcms/cms": "4.5.11",
    "craftcms/mailgun": "^3.0.0",
    "craftcms/redactor": "3.0.4",
    "dodecastudio/craft-blurhash": "2.0.5",
    "mmikkel/retcon": "2.7.5",
    "nystudio107/craft-closure": "^1.0.0",
    "nystudio107/craft-emptycoalesce": "^4.0.0",
    "nystudio107/craft-minify": "4.0.0-beta.2",
    "nystudio107/craft-retour": "4.1.14",
    "nystudio107/craft-seomatic": "4.0.35",
    "nystudio107/craft-typogrify": "4.0.1",
    "nystudio107/craft-vite": "4.0.6",
    "ostark/craft-relax": "2.0.1",
    "putyourlightson/craft-blitz": "4.9.0",
    "putyourlightson/craft-blitz-recommendations": "2.1.3",
    "putyourlightson/craft-sprig": "2.7.2",
    "sebastianlenz/linkfield": "2.1.5",
    "spacecatninja/imager-x": "4.2.3",
    "spacecatninja/imager-x-do-spaces-driver": "3.0.0",
    "spicyweb/craft-batch-actions": "1.3.1",
    "topshelfcraft/wordsmith": "4.2.0",
    "vaersaagod/dospaces": "^2.0.0",
    "verbb/expanded-singles": "2.0.5",
    "verbb/image-resizer": "3.0.8",
    "verbb/navigation": "2.0.22",
    "verbb/smith": "^2.0.0",
    "verbb/super-table": "3.0.12",
    "verbb/tablemaker": "4.0.7",
    "vlucas/phpdotenv": "^5.4.0"
},

Blitz Configuration (blitz.php):


<?php

/**
 * @copyright Copyright (c) PutYourLightsOn
 */

/**
 * Blitz config.php
 *
 * This file exists only as a template for the Blitz settings.
 * It does nothing on its own.
 *
 * Don't edit this file, instead copy it to 'craft/config' as 'blitz.php'
 * and make your changes there to override default settings.
 *
 * Once copied to 'craft/config', this file will be multi-environment aware as
 * well, so you can have different settings groups for each environment, just as
 * you do for 'general.php'
 */

use craft\helpers\App;

$cachedPages = [

  'includedUriPatterns' => [
    ['uriPattern' => 'news/.*'],
    ['uriPattern' => 'sports/.*'],
  ]

];

return [
  '*' => [
    // With this setting enabled, Blitz will log detailed messages to `storage/logs/blitz.log`.
    //'debug' => false,

    // With this setting enabled, Blitz will provide template performance hints in a utility.
    'hintsEnabled' => true,

    // With this setting enabled, Blitz will begin caching pages according to the included/excluded URI patterns. Disable this setting to prevent Blitz from caching any new pages.
    'cachingEnabled' => App::env('ENABLE_BLITZ_CACHING') ?? false,

    // Determines when and how the cache should be refreshed.
    // - `0`: Expire the cache, regenerate manually
    // - `1`: Clear the cache, regenerate manually or organically
    // - `2`: Expire the cache and regenerate in a queue job
    // - `3`: Clear the cache and regenerate in a queue job
    'refreshMode' => 2,

    // The URI patterns to include in caching. Set `siteId` to a blank string to indicate all sites.
    ...(App::env('DEV_MODE') ? [] : $cachedPages),

    // The storage type to use.
    'cacheStorageType' => 'putyourlightson\blitz\drivers\storage\FileStorage',

    // The storage settings.
    'cacheStorageSettings' => [
      'folderPath' => '@assetsRoot/cache/blitz',
      'createGzipFiles' => true,
      'countCachedFiles' => true,
    ],

    // With this setting enabled, Blitz will statically include templates using Server-Side Includes (SSI), which must be enabled on the web server.
    'ssiEnabled' => true,

    // Whether an `X-Powered-By: Blitz` header should be sent.
    'sendPoweredByHeader' => false,
  ],
];
diegocosta-dev commented 10 months ago

@bencroker

Issue Update:

I've identified that the issue is related to the Relex plugin. The error only occurs when this plugin is installed and enabled.

image
diegocosta-dev commented 10 months ago

@bencroker

Issue Update:

I've discovered that the issue is not with Blitz, and I apologize for any confusion. The problem lies in the configuration of the Relex plugin.

In the Relex plugin configuration, I had the following line of code:


return [
    /**
     * Queue
     *
     * (bool) true means: Use the queue the plugin provides
     * (bool) false means: Use the default queue behavior of Craft
     */
    'hashedQueue' => false,
];
bencroker commented 10 months ago

Ok, glad to hear you figured it out!