When testing commerce (out of the box) with sample templates from the vendor package, I'm getting a Deprecation Error when trying to add items to the cart.
Deprecation Error:
The setting of “saleAmount” has been deprecated. “saleAmount” is automatically calculated.
Stacktrace:
craft\errors\DeprecationException: The setting of “saleAmount” has been deprecated. “saleAmount” is automatically calculated. in /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Component.php:180
Stack trace:
#0 /Users/jameskrill/Sites/thedougycenter/html/vendor/craftcms/commerce/src/models/LineItem.php(332): craft\services\Deprecator->log('LineItem::setSa...', 'The setting of ...')
#1 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Component.php(180): craft\commerce\models\LineItem->setSaleAmount(0)
#2 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/behaviors/AttributeTypecastBehavior.php(241): yii\base\Component->__set('saleAmount', 0)
#3 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/behaviors/AttributeTypecastBehavior.php(337): yii\behaviors\AttributeTypecastBehavior->typecastAttributes()
#4 [internal function]: yii\behaviors\AttributeTypecastBehavior->afterValidate(Object(yii\base\Event))
#5 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Component.php(627): call_user_func(Array, Object(yii\base\Event))
#6 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Model.php(398): yii\base\Component->trigger('afterValidate')
#7 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Model.php(369): yii\base\Model->afterValidate()
#8 /Users/jameskrill/Sites/thedougycenter/html/vendor/craftcms/commerce/src/elements/traits/OrderValidatorsTrait.php(153): yii\base\Model->validate()
#9 [internal function]: craft\commerce\elements\Order->validateLineItems('lineItems', NULL, Object(yii\validators\InlineValidator))
#10 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/validators/InlineValidator.php(72): call_user_func(Array, 'lineItems', NULL, Object(yii\validators\InlineValidator))
#11 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/validators/Validator.php(257): yii\validators\InlineValidator->validateAttribute(Object(craft\commerce\elements\Order), 'lineItems')
#12 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Model.php(367): yii\validators\Validator->validateAttributes(Object(craft\commerce\elements\Order), Array)
#13 /Users/jameskrill/Sites/thedougycenter/html/vendor/craftcms/commerce/src/controllers/CartController.php(343): yii\base\Model->validate(Array)
#14 /Users/jameskrill/Sites/thedougycenter/html/vendor/craftcms/commerce/src/controllers/CartController.php(246): craft\commerce\controllers\CartController->_returnCart()
#15 [internal function]: craft\commerce\controllers\CartController->actionUpdateCart()
#16 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#17 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#18 /Users/jameskrill/Sites/thedougycenter/html/vendor/craftcms/cms/src/web/Controller.php(178): yii\base\Controller->runAction('update-cart', Array)
#19 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('update-cart', Array)
#20 /Users/jameskrill/Sites/thedougycenter/html/vendor/craftcms/cms/src/web/Application.php(291): yii\base\Module->runAction('commerce/cart/u...', Array)
#21 /Users/jameskrill/Sites/thedougycenter/html/vendor/craftcms/cms/src/web/Application.php(559): craft\web\Application->runAction('commerce/cart/u...', Array)
#22 /Users/jameskrill/Sites/thedougycenter/html/vendor/craftcms/cms/src/web/Application.php(270): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#23 /Users/jameskrill/Sites/thedougycenter/html/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#24 /Users/jameskrill/Sites/thedougycenter/html/web/index.php(21): yii\base\Application->run()
#25 /Users/jameskrill/.composer/vendor/laravel/valet/server.php(158): require('/Users/jameskri...')
#26 {main}
vendor/craftcms/commerce/templates/shop to templates/shop/shop which redirects to /shop/productsI was able to xdebug the issue down to something inside the validate() method when it was going over lineItems one by one. That's as far as I made it in the debugging.
Gif of issue happening: https://share.getcloudapp.com/JruWdwXw
Thanks, this has been fixed for the next release.
Most people wouldn't hit this bug, except you seem to have a higher php warning/error level set. Deprecation errors are normally just logged and do throw an actual exception. Are you modifying the throwExceptions config setting in your deprecator component in your app.php?
Oh you're right! I guess this is the first time I've seen a deprecation error in Yii (Craft). Yes, usually I try and keep my error warnings pretty strict. Thanks for responding so quickly and fixing it. Cheers!
@lukeholder this is still happening for me, testing with dev-develop:
craft_local_1 | [2020-04-16 10:51:19] craftcms.ERROR: craft\errors\DeprecationException: The setting of “saleAmount” has been deprecated. “saleAmount” is automatically calculated. in /app/vendor/composer/yiisoft/yii2/base/Component.php:180
Stack trace:
#0 /app/vendor/composer/craftcms/commerce/src/models/LineItem.php(374): craft\services\Deprecator->log('LineItem::setSa...', 'The setting of ...')
#1 /app/vendor/composer/yiisoft/yii2/base/Component.php(180): craft\commerce\models\LineItem->setSaleAmount('0.0000')
#2 /app/vendor/composer/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set('saleAmount', '0.0000')
#3 /app/vendor/composer/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\commerce\models\LineItem), Array)
#4 /app/vendor/composer/craftcms/commerce/src/services/LineItems.php(163): yii\base\BaseObject->__construct(Array)
#5 /app/vendor/composer/craftcms/commerce/src/elements/Order.php(2095): craft\commerce\services\LineItems->getAllLineItemsByOrderId(759684)
#6 /app/vendor/composer/craftcms/commerce/src/elements/Order.php(1512): craft\commerce\elements\Order->getLineItems()
#7 /app/vendor/composer/craftcms/commerce/src/elements/Order.php(1605): craft\commerce\elements\Order->recalculate()
#8 /app/vendor/composer/craftcms/cms/src/services/Elements.php(2125): craft\commerce\elements\Order->afterSave(false)
#9 /app/vendor/composer/craftcms/cms/src/services/Elements.php(531): craft\services\Elements->_saveElementInternal(Object(craft\commerce\elements\Order), false, false, true)
#10 /app/vendor/composer/craftcms/commerce/src/services/Carts.php(110): craft\services\Elements->saveElement(Object(craft\commerce\elements\Order), false)
#11 /app/vendor/composer/craftcms/commerce/src/controllers/CartController.php(413): craft\commerce\services\Carts->getCart(true)
#12 /app/vendor/composer/craftcms/commerce/src/controllers/CartController.php(79): craft\commerce\controllers\CartController->_getCart(true)
#13 [internal function]: craft\commerce\controllers\CartController->actionUpdateCart()
#14 /app/vendor/composer/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#15 /app/vendor/composer/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#16 /app/vendor/composer/craftcms/cms/src/web/Controller.php(178): yii\base\Controller->runAction('update-cart', Array)
#17 /app/vendor/composer/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('update-cart', Array)
#18 /app/vendor/composer/craftcms/cms/src/web/Application.php(291): yii\base\Module->runAction('commerce/cart/u...', Array)
#19 /app/vendor/composer/craftcms/cms/src/web/Application.php(559): craft\web\Application->runAction('commerce/cart/u...', Array)
#20 /app/vendor/composer/craftcms/cms/src/web/Application.php(270): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#21 /app/vendor/composer/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#22 /app/public/index.php(5): yii\base\Application->run()
#23 {main} {"trace":[],"memory":10196168,"category":"craft\\errors\\DeprecationException","exception":"[object] (craft\\errors\\DeprecationException(code: 0): The setting of “saleAmount” has been deprecated. “saleAmount” is automatically calculated. at /app/vendor/composer/yiisoft/yii2/base/Component.php:180)"} []
@lukeholder like @timkelty we are still running into this, let me know if you require any further details from me.
We just released 3.1.2 that fixed this issue. @timkelty @samhibberd
I'm _still_ getting the error.
It's happening on for me in the "Updating search indexes" job spawned when saving any product:

dev-develop#9d31bbf73ea1aacc1f4148f63a944a24bc575f81 as 3.1.2