craftcms / commerce

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

[4.x][5.x]: Tidy up UserException thrown during pending user purge? #3686

Open samhibberd opened 2 hours ago

samhibberd commented 2 hours ago

What happened?

Could the UserException thrown during the pending user purge be reworked, we use sentry to monitor exceptions and this has added ~100k issues to our usage:

https://github.com/craftcms/commerce/blob/8f6a112deb4e01536d528dadc4e6351b9fc8f075/src/services/Orders.php#L188-L200

As the user is correctly not being deleted as the user (customer) has an order, could this not be handled - the activation code / state be removed, or event added to the user purge logic so commerce could hook into that and exclude users that have an order?

Also is there a reason you don't return theisValid = false and intead throw the excpetion?

You may set [[\yii\base\ModelEvent::$isValid]] to false to prevent the element from getting deleted.

Impacts both 4.x and 5.x

Craft CMS version

4.10.8

Craft Commerce version

4.6.7

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

linear[bot] commented 2 hours ago

PT-2161 [4.x][5.x]: