isotope / core

Core repository of Isotope eCommerce, an eCommerce extension for Contao Open Source CMS
https://isotopeecommerce.org
136 stars 107 forks source link

Internal name attributes - generate/allow only names without special characters #2519

Closed xprojects-de closed 4 months ago

xprojects-de commented 6 months ago

If an attribute is created with special characters (e.g. Größen), the following error occures.

RuntimeException:
Invalid column name "größen" in Contao\Database\{closure}()

  at vendor/contao/core-bundle/src/Resources/contao/library/Contao/Database/Statement.php:153
  at Contao\Database\Statement::Contao\Database\{closure}('größen')
  at array_map(object(Closure), array('pid', 'gid', 'tstamp', 'language', 'dateAdded', 'type', 'orderPages', 'inherit', 'fallback', 'alias', 'gtin', 'sku', 'name', 'teaser', 'description', 'meta_title', 'meta_description', 'meta_keywords', 'baseprice', 'shipping_weight', 'shipping_exempt', 'shipping_price', 'images', 'protected', 'groups', 'guests', 'cssID', 'published', 'start', 'stop', 'größen', 'shipping_pickup', 'clothingsizes', 'simple_erp_disable_on_zero', 'simple_erp_count'))
     (vendor/contao/core-bundle/src/Resources/contao/library/Contao/Database/Statement.php:148)
  at Contao\Database\Statement->set(array('pid' => 0, 'gid' => 0, 'tstamp' => 0, 'language' => '', 'dateAdded' => 0, 'type' => 4, 'orderPages' => 'a:1:{i:0;s:2:"61";}', 'inherit' => null, 'fallback' => '', 'alias' => '', 'gtin' => '', 'sku' => '', 'name' => 'Birgsau Oberstdorf', 'teaser' => '...', 'description' => '...', 'meta_title' => '', 'meta_description' => null, 'meta_keywords' => null, 'baseprice' => '', 'shipping_weight' => 'a:1:{s:4:"unit";s:2:"kg";}', 'shipping_exempt' => '', 'shipping_price' => '0.00', 'images' => 'a:1:{i:0;a:5:{s:3:"src";s:25:"dsc08792-bearbeitet-1.jpg";s:3:"alt";s:0:"";s:4:"link";s:0:"";s:4:"desc";s:0:"";s:9:"translate";s:4:"none";}}', 'protected' => '', 'groups' => null, 'guests' => '', 'cssID' => '', 'published' => '', 'start' => '', 'stop' => '', 'größen' => 0, 'shipping_pickup' => '', 'clothingsizes' => 0, 'simple_erp_disable_on_zero' => '', 'simple_erp_count' => ''))
     (vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php:934)
  at Contao\DC_Table->copy()
     (vendor/contao/core-bundle/src/Resources/contao/classes/Backend.php:667)
  at Contao\Backend->getBackendModule('iso_products', null)
     (vendor/contao/core-bundle/src/Resources/contao/controllers/BackendMain.php:168)
  at Contao\BackendMain->run()
     (vendor/contao/core-bundle/src/Controller/BackendController.php:49)
  at Contao\CoreBundle\Controller\BackendController->mainAction()
     (vendor/symfony/http-kernel/HttpKernel.php:163)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:75)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:202)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/index.php:44)                

Reason: Contao checks the ColumnName for special characters. https://github.com/contao/contao/blob/5dc0202c2a5fb08330e898595bebffc4b55ceca3/core-bundle/src/Resources/contao/library/Contao/Database/Statement.php#L151

I think it would make sense to only allow internal names without special characters. Bildschirmfoto 2024-03-08 um 07 53 24

aschempp commented 4 months ago

Fixed in fffed20fd7e71edb620e574595d67032cf36cb38