craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
227 stars 170 forks source link

[5.x]: Creating a product with a ' character in the title breaks variant creation #3516

Closed TheFunkyMonk closed 6 months ago

TheFunkyMonk commented 6 months ago

What happened?

Description

When creating a new product with the name Pet'Golò, the initial draft seems to save correctly but when I select "New product variant" and try to create a variant, I trigger the following error:

2024-05-22 09:36:20 [web.ERROR] [yii\web\HttpException:400] yii\web\BadRequestHttpException: Unable to verify your data submission. in /var/www/html/vendor/yiisoft/yii2/web/Controller.php:220
Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/web/Controller.php(175): yii\web\Controller->beforeAction(Object(yii\base\InlineAction))
#1 /var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(98): craft\web\Controller->beforeAction(Object(yii\base\InlineAction))
#2 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(176): craft\controllers\ElementsController->beforeAction(Object(yii\base\InlineAction))
#3 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('edit', Array)
#4 /var/www/html/vendor/craftcms/cms/src/web/Application.php(349): yii\base\Module->runAction('elements/edit', Array)
#5 /var/www/html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('elements/edit', Array)
#6 /var/www/html/vendor/craftcms/cms/src/web/Application.php(317): yii\web\Application->handleRequest(Object(craft\web\Request))
#7 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#8 /var/www/html/web/index.php(12): yii\base\Application->run()
#9 {main} {"memory":4022872,"exception":"[object] (yii\\web\\BadRequestHttpException(code: 0): Unable to verify your data submission. at /var/www/html/vendor/yiisoft/yii2/web/Controller.php:220)"} 

Additionally, I'm seeing this in my browser console when the variant slideout opens:

2024-05-22 at 09 34 00

This seems to be an issue only with the initial draft/entry creation; if we change the product name to something like "Test" it can successfully be created/renamed to Pet'Golò.

Steps to reproduce

  1. Create a new product with the name Pet'Golò
  2. Create a variant and save

Expected behavior

Variant is created and product can be saved

Actual behavior

Above errors are triggered

Craft CMS version

5.1.4

Craft Commerce version

5.0.7

PHP version

8.2.19

Operating system and version

Linux 6.5.0-15-generic

Database type and version

MySQL 8.0.33

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

CKEditor 4.0.6 Colour Swatches 5.0.0 Control Panel CSS 3.0.0 Craft Commerce 5.0.7 Default Dashboard 3.0.0 Field Manager 4.0.0 Guide 4.0.0-beta.1 ImageOptimize 5.0.1 Image Resizer 4.0.0 Neo 5.0.0-beta.10 No-Cache 3.0.2 PayPal Checkout for Craft Commerce 3.0.0 Redirects 5.0.0 Retcon 3.0.0 SEO 5.0.3 Servd Assets and Helpers 4.0.3 Sprig 3.0.2 Stripe for Craft Commerce 5.0.1

linear[bot] commented 6 months ago

PT-1755 [5.x]: Creating a product with a ' character in the title breaks variant creation

nfourtythree commented 6 months ago

Hi @TheFunkyMonk

Thank you for your message. Unfortunately, we are unable to replicate your issue.

Here is a video of everything working as expected on the latest version of Craft 5 and Commerce 5

https://github.com/craftcms/commerce/assets/266453/0fbf37a4-bbdd-4e91-ac5f-9000c5521114

Could you clear the caches and try again? If that doesn't make any difference, could you try disabling other plugins to see if that is having any effect?

Thanks!

TheFunkyMonk commented 6 months ago

Hey there! To clarify, this only happens when creating a new product. Editing an existing product to change the name to Pet'Golò and adding a variant before completing the product creation triggers this issue.

Clearing caches has no effect for us; are you able to repro by creating a new product with the name Pet'Golò and adding a variant?

lukeholder commented 6 months ago

@TheFunkyMonk I am able to create a brand new product and brand new variant with Pet'Golò as the title. I was also able to create a new draft.

Something else is going on. Could you send your DB with composer.json and composer.lock to support@craftcms.com and reference this issue and we will see if we can reproduce with your data/plugins.

brandonkelly commented 6 months ago

Commerce 5.0.8 is out now with a fix for this. Thanks for reporting!