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

Missing table names in query when trying to load front-end and back-end Super Table data/fields #509

Open
rowansentesy opened this issue Mar 8, 2023 · 1 comment

Comments

@rowansentesy
Copy link

Describe the bug

I am working on an update from Craft 2.x to Craft 4.x and was just able to successfully get to Craft CMS 4 without the error:
'You need to be on at least Super Table 2.7.1 before you can update to Super Table 3.0.7'.

Now, I have a different issue where I am trying to load a Global that has several super table variables.
The same issues shows on the site when trying to view a template that is accessing the same Globals.

See screenshot of full error
https://i.gyazo.com/031f5a373cf8806d69d36242a75edb1d.png

The erroneous query is:

SELECT COUNT(*)
FROM (SELECT `elements`.`id` AS `elementsId`, `elements_sites`.`id` AS `elementsSitesId`, `content`.`id` AS `contentId`
FROM `craft_elements` `elements`
INNER JOIN `craft_supertableblocks` `supertableblocks` ON `supertableblocks`.`id` = `elements`.`id`
INNER JOIN `craft_supertableblocks_owners` `supertableblocks_owners` ON (`supertableblocks_owners`.`blockId` = `elements`.`id`) AND (`supertableblocks_owners`.`ownerId`=13284)
INNER JOIN `craft_elements_sites` `elements_sites` ON `elements_sites`.`elementId` = `elements`.`id`
INNER JOIN `` `content` ON `content`.`elementId` = `elements`.`id`
WHERE (`supertableblocks`.`fieldId`=83) AND (`elements`.`archived`=FALSE) AND ((`elements`.`enabled`=TRUE) AND (`elements_sites`.`enabled`=TRUE)) AND (`elements`.`dateDeleted` IS NULL) AND (`elements`.`draftId` IS NULL) AND (`elements`.`revisionId` IS NULL)) `subquery`
INNER JOIN `craft_elements` `elements` ON `elements`.`id` = `subquery`.`elementsId`
INNER JOIN `craft_elements_sites` `elements_sites` ON `elements_sites`.`id` = `subquery`.`elementsSitesId`
INNER JOIN `craft_supertableblocks` `supertableblocks` ON `supertableblocks`.`id` = `subquery`.`elementsId`
INNER JOIN `craft_supertableblocks_owners` `supertableblocks_owners` ON (`supertableblocks_owners`.`blockId` = `elements`.`id`) AND (`supertableblocks_owners`.`ownerId`=13284)
INNER JOIN `` `content` ON `content`.`id` = `subquery`.`contentId`

The correct SQL replaces `` with craft_content.

SELECT COUNT(*)
FROM (SELECT `elements`.`id` AS `elementsId`, `elements_sites`.`id` AS `elementsSitesId`, `content`.`id` AS `contentId`
FROM `craft_elements` `elements`
INNER JOIN `craft_supertableblocks` `supertableblocks` ON `supertableblocks`.`id` = `elements`.`id`
INNER JOIN `craft_supertableblocks_owners` `supertableblocks_owners` ON (`supertableblocks_owners`.`blockId` = `elements`.`id`) AND (`supertableblocks_owners`.`ownerId`=13284)
INNER JOIN `craft_elements_sites` `elements_sites` ON `elements_sites`.`elementId` = `elements`.`id`
INNER JOIN `craft_content` `content` ON `content`.`elementId` = `elements`.`id`
WHERE (`supertableblocks`.`fieldId`=83) AND (`elements`.`archived`=FALSE) AND ((`elements`.`enabled`=TRUE) AND (`elements_sites`.`enabled`=TRUE)) AND (`elements`.`dateDeleted` IS NULL) AND (`elements`.`draftId` IS NULL) AND (`elements`.`revisionId` IS NULL)) `subquery`
INNER JOIN `craft_elements` `elements` ON `elements`.`id` = `subquery`.`elementsId`
INNER JOIN `craft_elements_sites` `elements_sites` ON `elements_sites`.`id` = `subquery`.`elementsSitesId`
INNER JOIN `craft_supertableblocks` `supertableblocks` ON `supertableblocks`.`id` = `subquery`.`elementsId`
INNER JOIN `craft_supertableblocks_owners` `supertableblocks_owners` ON (`supertableblocks_owners`.`blockId` = `elements`.`id`) AND (`supertableblocks_owners`.`ownerId`=13284)
INNER JOIN `craft_content` `content` ON `content`.`id` = `subquery`.`contentId`

This appears to possibly be an issue with yii2, it seems like the line of code is quite simple just asking for a ->count()
craft/vendor/verbb/super-table/src/fields/SuperTableField.php
Line 810

Steps to reproduce

  1. Craft 2.7.4, install Supertable 1.0.6 (on PHP 5.6)
  2. Update to Craft 3.x, Super Table 2.7.4 (PHP 8.
  3. Update to Craft 4.x, Super Table 3.0.7
  4. Try to view front-end page showing Super Table data or back-end view/edit of Super Table data

Craft CMS version

4.4.0

Plugin version

3.0.7

Multi-site?

no

Additional context

No response

@smalomo
Copy link

smalomo commented Apr 5, 2023

I'm experiencing the same issue, upgrading from Craft 2.x to 4.x
super-table: 3.0.8.1
craftcms: 4.4.6.1

@rowansentesy did you ever resolve this issue?

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

2 participants