Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Exception when deleting Supertable field (and Blitz is active) #567

Open
scholejo opened this issue Sep 5, 2024 · 0 comments
Open

Comments

@scholejo
Copy link

scholejo commented Sep 5, 2024

Describe the bug

When attempting to delete a Supertable field from inside a matrix block type, I get a column not found exception for a field that doesn't even belong to that matrix block type. This happens when deleting the field via CP and when applying the project config. From the stack trace below it seems that the reason is that Blitz is calling ElementHelper::isDraftOrRevision on a SuperTableBlockElement. When I disable Blitz, the deletion works fine. But it was a bit of a pain to deploy my changes to a production system like that.

#0 /app/vendor/yiisoft/yii2/db/Command.php(1325): yii\db\Schema->convertException(Object(PDOException), 'SELECT `element...')
#1 /app/vendor/yiisoft/yii2/db/Command.php(1186): yii\db\Command->internalExecute('SELECT `element...')
#2 /app/vendor/yiisoft/yii2/db/Command.php(431): yii\db\Command->queryInternal('fetch', NULL)
#3 /app/vendor/yiisoft/yii2/db/Query.php(287): yii\db\Command->queryOne()
#4 /app/vendor/craftcms/cms/src/db/Query.php(280): yii\db\Query->one(NULL)
#5 /app/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1672): craft\db\Query->one(NULL)
#6 /app/vendor/craftcms/cms/src/services/Elements.php(887): craft\elements\db\ElementQuery->one()
#7 /app/vendor/craftcms/cms/src/services/Elements.php(825): craft\services\Elements->_elementById('id', 617727, 'craft\\elements\\...', 1, Array)
#8 /app/vendor/craftcms/cms/src/elements/MatrixBlock.php(343): craft\services\Elements->getElementById(617727, NULL, 1)
#9 /app/vendor/craftcms/cms/src/helpers/ElementHelper.php(510): craft\elements\MatrixBlock->getOwner()
#10 /app/vendor/craftcms/cms/src/helpers/ElementHelper.php(512): craft\helpers\ElementHelper::isDraftOrRevision(Object(craft\elements\MatrixBlock))
#11 /app/vendor/putyourlightson/craft-blitz/src/services/RefreshCacheService.php(279): craft\helpers\ElementHelper::isDraftOrRevision(Object(verbb\supertable\elements\SuperTableBlockElement))
#12 /app/vendor/putyourlightson/craft-blitz/src/Blitz.php(393): putyourlightson\blitz\services\RefreshCacheService->isRefreshableElement(Object(verbb\supertable\elements\SuperTableBlockElement))
#13 [internal function]: putyourlightson\blitz\Blitz->putyourlightson\blitz\{closure}(Object(craft\events\DeleteElementEvent))
#14 /app/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(craft\events\DeleteElementEvent))
#15 /app/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger('craft\\services\\...', 'beforeDeleteEle...', Object(craft\events\DeleteElementEvent))
#16 /app/vendor/craftcms/cms/src/services/Elements.php(2116): yii\base\Component->trigger('beforeDeleteEle...', Object(craft\events\DeleteElementEvent))
#17 /app/vendor/verbb/super-table/src/services/Service.php(419): craft\services\Elements->deleteElement(Object(verbb\supertable\elements\SuperTableBlockElement))
#18 /app/vendor/craftcms/cms/src/services/ProjectConfig.php(1159): verbb\supertable\services\Service->handleDeletedBlockType(Object(craft\events\ConfigEvent))

Steps to reproduce

  1. Have a Matrix field with Supertable fields nested inside
  2. I think it's necessary to have actual content in that nested Supertable field
  3. Have Blitz installed and enabled
  4. Attempt to delete the Supertable field from the Matrix Block Type

Craft CMS version

4.12.0

Plugin version

3.0.14

Multi-site?

Yes

Additional context

Blitz Version: 4.23.0
PHP Version: 8.2.19

This might partly be a duplicate of #443, but I don't see Blitz mentioned there.
I've already opened an issue here putyourlightson/craft-blitz#709, but it looks like the incompatibility is on Supertable's side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant