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

DB error on tracked includes diagnostics #653

Closed borisklotz closed 5 months ago

borisklotz commented 5 months ago

Bug Report

After upgrading to version 4.16.0 I get a DB error when I try to visit the tracked includes diagnostics (/admin/blitz/diagnostics/includes)

Database Exception – [yii\db\Exception](https://www.yiiframework.com/doc-2.0/yii-db-exception.html)
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: text = bigint
LINE 5: WHERE "siteId"=$1) "indexes" ON SUBSTR(uri, 49) = "indexes"....
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
The SQL being executed was: SELECT COUNT(*)
FROM "blitz_caches" "caches"
INNER JOIN (SELECT *
FROM "blitz_includes"
WHERE "siteId"=1) "indexes" ON SUBSTR(uri, 49) = "indexes"."index"
LEFT JOIN (SELECT "cacheId", count(*) AS "elementCount"
FROM "blitz_elementcaches"
GROUP BY "cacheId") "elements" ON "caches"."id" = "elements"."cacheId"
LEFT JOIN (SELECT "cacheId", count(*) AS "elementQueryCount"
FROM "blitz_elementquerycaches"
GROUP BY "cacheId") "elementquerycaches" ON "caches"."id" = "elementquerycaches"."cacheId"
WHERE ("caches"."siteId"=1) AND ("uri" LIKE '%\_includes?action=%')

Our installation is running on PostgreSQL 13

Plugin Version

4.16.0

Craft CMS Version

4.8.7

PHP Version

8.1.18

bencroker commented 5 months ago

Thanks for reporting this. Are you using a Postgres database, by any chance?

bencroker commented 5 months ago

Turns out it was a bug with Postgres, fixed in https://github.com/putyourlightson/craft-blitz/commit/4fa8d978a8c3315db8041e8c32f144b1ae031588 for the next release.

You can test it by running composer require "putyourlightson/craft-blitz:v4.x-dev as 4.16.1".

bencroker commented 5 months ago

Released in 4.16.1.