Skip to content

Instantly share code, notes, and snippets.

@amenk
Created November 5, 2022 17:55
Show Gist options
  • Save amenk/52e6d474e6e85025fb160dfc531b7ab1 to your computer and use it in GitHub Desktop.
Save amenk/52e6d474e6e85025fb160dfc531b7ab1 to your computer and use it in GitHub Desktop.
Contao 3.5.40 MySQL 8 Patch
diff --git a/public/system/modules/core/drivers/DC_Table.php b/public/system/modules/core/drivers/DC_Table.php
index 5f099f9..520d326 100644
--- a/public/system/modules/core/drivers/DC_Table.php
+++ b/public/system/modules/core/drivers/DC_Table.php
@@ -5459,7 +5459,7 @@ class DC_Table extends \DataContainer implements \listable, \editable
$arrProcedure[] = "id IN(" . implode(',', array_map('\intval', $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'])) . ")";
}
- $objFields = $this->Database->prepare("SELECT DISTINCT " . $what . " FROM " . $this->strTable . ((is_array($arrProcedure) && strlen($arrProcedure[0])) ? ' WHERE ' . implode(' AND ', $arrProcedure) : ''))
+ $objFields = $this->Database->prepare("SELECT DISTINCT " . \Database::quoteIdentifier($what) . " FROM " . $this->strTable . ((is_array($arrProcedure) && strlen($arrProcedure[0])) ? ' WHERE ' . implode(' AND ', $arrProcedure) : ''))
->execute($arrValues);
// Begin select menu
diff --git a/public/system/modules/core/library/Contao/Database.php b/public/system/modules/core/library/Contao/Database.php
index 454ac11..daa9e7b 100644
--- a/public/system/modules/core/library/Contao/Database.php
+++ b/public/system/modules/core/library/Contao/Database.php
@@ -602,7 +602,7 @@ abstract class Database
*/
public static function quoteIdentifier($strName)
{
- if (strtolower($strName) == 'rows')
+ if (in_array(strtolower($strName), ['rows', 'groups']))
{
$strName = '`'.$strName.'`';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment