Skip to content

Commit

Permalink
Fixed #13130
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Apr 28, 2023
1 parent 6387157 commit bc46f3d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- “Element query executed before Craft is fully initialized” warnings now include a stack trace.
- Fixed a user enumeration timing attack vulnerability.
- Fixed a SQL error that could occur when upgrading to Craft 4, if any `matrixblocks` table rows referenced nonexistent element IDs. ([#13121](https://github.com/craftcms/cms/issues/13121))
- Fixed a SQL error that could occur when upgrading to Craft 4, if anything triggered an asset or volume query. ([#13130](https://github.com/craftcms/cms/issues/13130))
- Fixed a SQL error that occurred when deleting a category group on PostgreSQL, when configured with a table prefix. ([#13127](https://github.com/craftcms/cms/issues/13127))
- Fixed a JavaScript error that could occur on the control panel login form.

Expand Down
6 changes: 5 additions & 1 deletion src/elements/db/AssetQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,6 @@ protected function beforePrepare(): bool
'assets.uploaderId',
'assets.filename',
'assets.kind',
'assets.alt',
'assets.width',
'assets.height',
'assets.size',
Expand All @@ -910,6 +909,11 @@ protected function beforePrepare(): bool
'volumeFolders.path AS folderPath',
]);

// todo: cleanup after next breakpoint
if (Craft::$app->getDb()->columnExists(Table::ASSETS, 'alt')) {
$this->query->addSelect(['assets.alt']);
}

if ($this->volumeId) {
if ($this->volumeId === ':empty:') {
$this->subQuery->andWhere(['assets.volumeId' => null]);
Expand Down
17 changes: 13 additions & 4 deletions src/services/Volumes.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,14 +586,11 @@ public function pruneDeletedField(): void
*/
private function _createVolumeQuery(): Query
{
return (new Query())
$query = (new Query())
->select([
'id',
'name',
'handle',
'fs',
'transformFs',
'transformSubpath',
'titleTranslationMethod',
'titleTranslationKeyFormat',
'sortOrder',
Expand All @@ -603,6 +600,18 @@ private function _createVolumeQuery(): Query
->from([Table::VOLUMES])
->where(['dateDeleted' => null])
->orderBy(['sortOrder' => SORT_ASC]);

// todo: cleanup after next breakpoint
$db = Craft::$app->getDb();
if ($db->columnExists(Table::VOLUMES, 'fs')) {
$query->addSelect([
'fs',
'transformFs',
'transformSubpath',
]);
}

return $query;
}

/**
Expand Down

0 comments on commit bc46f3d

Please sign in to comment.