Skip to content

Commit a0480e2

Browse files
committed
hotfix(snippets): strip double backticks around getTableName() result (#293)
$modx->getTableName() already returns the table name escaped with backticks (e.g. `modx_ms3_product_files`). PR #282 wrapped it in another pair of backticks in the SQL template — runtime SQL had triple backticks and any `includeThumbs` call from msProducts / msCart / msGetOrder errored out with: Error 42000: You have an error in your SQL syntax ... near '`` `main` WHERE ...' Catalog listings using `includeThumbs` returned empty results in 1.11.0-beta1 — see issue #293. Removed the outer backticks around %4$s in the sprintf template; added a comment so future readers don't add them back. Caught early — few downloads of 1.11.0-beta1 yet. Re-tagging the existing version instead of bumping to 1.11.1-beta1.
1 parent 7915dde commit a0480e2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

core/components/minishop3/src/Utils/ProductThumbnailJoin.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ public static function buildLeftJoinOn(
2828
return '1 = 0';
2929
}
3030

31+
// xPDO::getTableName() already returns the name escaped with backticks
32+
// (e.g. "`modx_ms3_product_files`"). DO NOT wrap %4$s in extra backticks
33+
// — that produced triple backticks at runtime and an SQL syntax error
34+
// on `includeThumbs=...` (regression introduced in #282 / 1.11.0-beta1).
3135
$filesTable = $modx->getTableName(msProductFile::class);
3236

3337
return sprintf(
3438
'`%1$s`.product_id = `%2$s`.id'
3539
. ' AND `%1$s`.parent_id != 0'
3640
. ' AND `%1$s`.path LIKE \'%%/%3$s/%%\''
3741
. ' AND `%1$s`.parent_id = ('
38-
. 'SELECT `main`.`id` FROM `%4$s` `main`'
42+
. 'SELECT `main`.`id` FROM %4$s `main`'
3943
. ' WHERE `main`.`product_id` = `%2$s`.`id`'
4044
. ' AND `main`.`parent_id` = 0'
4145
. ' AND `main`.`type` = \'image\''

0 commit comments

Comments
 (0)