putyourlightson / craft-blitz

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

GitDeployer::updateFile(): Argument #1 ($value) must be of type string, null given #664

Closed brianjhanson closed 1 month ago

brianjhanson commented 1 month ago

Bug Report

It looks like maybe the types on GitDeployer::updateFile are a little too strong. $value has the ability to be null when using the FileStorage driver. It looks like updateFile would handle null values, but I'm getting a type error from PHP.

2024-05-14 22:40:15 [console.ERROR] [TypeError] putyourlightson\blitz\drivers\deployers\GitDeployer::updateFile(): Argument #1 ($value) must be of type string, null given, called in file/path/vendor/putyourlightson/craft-blitz/src/drivers/deployers/GitDeployer.php on line 147

{
  "trace": [
    "#0 file/path/vendor/putyourlightson/craft-blitz/src/drivers/deployers/GitDeployer.php(147): putyourlightson\\blitz\\drivers\\deployers\\GitDeployer->updateFile()",
    "#1 file/path/vendor/putyourlightson/craft-blitz/src/drivers/deployers/BaseDeployer.php(52): putyourlightson\\blitz\\drivers\\deployers\\GitDeployer->deployUrisWithProgress()",
    "#2 file/path/vendor/putyourlightson/craft-blitz/src/console/controllers/CacheController.php(587): putyourlightson\\blitz\\drivers\\deployers\\BaseDeployer->deployUris()",
    "#3 file/path/vendor/putyourlightson/craft-blitz/src/console/controllers/CacheController.php(309): putyourlightson\\blitz\\console\\controllers\\CacheController->deploy()",
    "#4 [internal function]: putyourlightson\\blitz\\console\\controllers\\CacheController->actionRefresh()",
    "#5 file/path/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()",
    "#6 file/path/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams()",
    "#7 file/path/vendor/yiisoft/yii2/console/Controller.php(180): yii\\base\\Controller->runAction()",
    "#8 file/path/vendor/yiisoft/yii2/base/Module.php(552): yii\\console\\Controller->runAction()",
    "#9 file/path/vendor/yiisoft/yii2/console/Application.php(180): yii\\base\\Module->runAction()",
    "#10 file/path/vendor/craftcms/cms/src/console/Application.php(91): yii\\console\\Application->runAction()",
    "#11 file/path/vendor/yiisoft/yii2/console/Application.php(147): craft\\console\\Application->runAction()",
    "#12 file/path/vendor/craftcms/cms/src/console/Application.php(122): yii\\console\\Application->handleRequest()",
    "#13 file/path/vendor/yiisoft/yii2/base/Application.php(384): craft\\console\\Application->handleRequest()",
    "#14 file/path/craft(13): yii\\base\\Application->run()",
    "#15 {main}"
  ],
  "memory": 30980064,
  "exception": "[object] (TypeError(code: 0): putyourlightson\\blitz\\drivers\\deployers\\GitDeployer::updateFile(): Argument #1 ($value) must be of type string, null given, called in file/path/vendor/putyourlightson/craft-blitz/src/drivers/deployers/GitDeployer.php on line 147 at file/path/vendor/putyourlightson/craft-blitz/src/drivers/deployers/GitDeployer.php:340)"
}

Diagnostics Report

Application Info

Installed Plugins

Loaded Modules

Blitz Plugin Settings

{
    "debug": true,
    "hintsEnabled": true,
    "cachingEnabled": true,
    "refreshCacheEnabled": true,
    "refreshMode": 3,
    "includedUriPatterns": [
        {
            "siteId": "",
            "uriPattern": ".*"
        },
        {
            "siteId": "",
            "uriPattern": "content-types\/.*"
        },
        {
            "siteId": "",
            "uriPattern": "content-types"
        },
        {
            "siteId": "",
            "uriPattern": "content-types\/index.html"
        },
        {
            "siteId": 1,
            "uriPattern": "content-topics\/.*"
        },
        {
            "siteId": 1,
            "uriPattern": "content-topics"
        },
        {
            "siteId": 1,
            "uriPattern": "content-topics\/index.html"
        },
        {
            "siteId": 1,
            "uriPattern": "news-insights\/archive\/.*"
        },
        {
            "siteId": 1,
            "uriPattern": "news-insights\/archive"
        }
    ],
    "excludedUriPatterns": [
        {
            "siteId": 1,
            "uriPattern": "\/block-library"
        }
    ],
    "cacheStorageType": "putyourlightson\\blitz\\drivers\\storage\\FileStorage",
    "cacheStorageSettings": {
        "folderPath": "@root\/blitz\/cache",
        "createGzipFiles": false,
        "countCachedFiles": true
    },
    "cacheStorageTypes": [],
    "cacheGeneratorType": "putyourlightson\\blitz\\drivers\\generators\\LocalGenerator",
    "cacheGeneratorSettings": {
        "concurrency": 5
    },
    "cacheGeneratorTypes": [],
    "customSiteUris": [
        {
            "siteId": 1,
            "uri": "\/search"
        },
        {
            "siteId": 1,
            "uri": "\/content-topics"
        }
    ],
    "cachePurgerType": "putyourlightson\\blitz\\drivers\\purgers\\DummyPurger",
    "cachePurgerSettings": [],
    "cachePurgerTypes": [],
    "deployerType": "putyourlightson\\blitz\\drivers\\deployers\\GitDeployer",
    "deployerSettings": {
        "gitRepositories": {
            "88bb7ef8-41f5-46d5-a33a-b5c80c65aff9": {
                "repositoryPath": "@root\/blitz\/repo",
                "branch": "develop",
                "remote": "origin"
            }
        },
        "commitMessage": "Blitz auto commit {{ now|date('c') }}",
        "username": "***",
        "personalAccessToken": "****************************************",
        "name": "DCVC Build",
        "email": "****",
        "commandsBefore": "cd \/storage\/av08978\/www\/dev\/releases\/306 && CRAFT_SITE_URL=https:\/\/craft4-dev.dcvc.com PUBLIC_SITE_URL=https:\/\/develop--dcvc-static.netlify.app sh blitz\/scripts\/pre-deploy.sh 2>&1 | tee -a storage\/logs\/blitz-pre-deploy.log",
        "commandsAfter": ""
    },
    "deployerTypes": [],
    "ssiEnabled": false,
    "ssiTagFormat": "<!--#include virtual=\"{uri}\" -->",
    "detectSsiEnabled": true,
    "esiEnabled": false,
    "queryStringCaching": 0,
    "includedQueryStringParams": [
        {
            "siteId": 1,
            "queryStringParam": ".*"
        }
    ],
    "excludedQueryStringParams": [
        {
            "siteId": 1,
            "queryStringParam": "gclid"
        },
        {
            "siteId": 1,
            "queryStringParam": "fbclid"
        }
    ],
    "apiKey": "",
    "generatePagesWithQueryStringParams": true,
    "purgeAssetImagesWhenChanged": true,
    "refreshCacheAutomaticallyForGlobals": true,
    "refreshCacheWhenElementMovedInStructure": true,
    "refreshCacheWhenElementSavedUnchanged": true,
    "refreshCacheWhenElementSavedNotLive": true,
    "cacheNonHtmlResponses": false,
    "trackElements": true,
    "trackElementQueries": true,
    "excludedTrackedElementQueryParams": [],
    "cacheElements": true,
    "cacheElementQueries": true,
    "cacheDuration": 0,
    "nonCacheableElementTypes": [],
    "sourceIdAttributes": [],
    "liveStatuses": [],
    "integrations": [
        "putyourlightson\\blitz\\drivers\\integrations\\FeedMeIntegration",
        "putyourlightson\\blitz\\drivers\\integrations\\SeomaticIntegration"
    ],
    "defaultCacheControlHeader": "no-store",
    "cacheControlHeader": "public, s-maxage=31536000, max-age=0",
    "cacheControlHeaderExpired": "public, max-age=5",
    "sendPoweredByHeader": false,
    "outputComments": false,
    "refreshCacheJobPriority": 10,
    "driverJobBatchSize": 100,
    "driverJobPriority": 100,
    "queueJobTtr": 300,
    "maxRetryAttempts": 10,
    "maxUriLength": 255,
    "mutexTimeout": 1,
    "commands": {
        "git": "REDACTED"
    },
    "injectScriptEvent": "DOMContentLoaded",
    "injectScriptPosition": 3
}

Recommendations

Site Tracking

bencroker commented 1 month ago

Thanks, Brian! Fixed in https://github.com/putyourlightson/craft-blitz/commit/f824ac54abd64d31cc004b7c4c516bcab1975dc7 for the next release.

bencroker commented 1 month ago

Released in 4.18.1 and 5.3.1.

brianjhanson commented 1 month ago

Beautiful. Thank you!