Deprecation error for Craft CMS fields with handle `order`
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
Description
I have a Craft CMS field with the handle order and I always receive a deprecation error because of this
The “order” element query param has been deprecated. Use “orderBy” instead.
The given stack trace looks like the following
27 | Deprecation error: The “order” element query param has been deprecated. Use “orderBy” instead. Called from /var/www/myspa/htdocs/vendor/craftcms/cms/src/elements/db/ElementQuery.php:402
26 | craft\elements\db\AssetQuery::__get("order") Called from /var/www/myspa/htdocs/vendor/yiisoft/yii2/base/ArrayableTrait.php:126
25 | craft\elements\db\AssetQuery::toArray() Called from /var/www/myspa/htdocs/vendor/yiisoft/yii2/helpers/BaseJson.php:157
24 | yii\helpers\BaseJson::processData(craft\elements\db\AssetQuery, [], "5cb088450119f2.57190485") Called from /var/www/myspa/htdocs/vendor/yiisoft/yii2/helpers/BaseJson.php:176
23 | yii\helpers\BaseJson::processData(["id" => "494", "typeId" => "1", "taxCategoryId" => "1", "shippingCategoryId" => "1", ...], [], "5cb088450119f2.57190485")
Called from /var/www/myspa/htdocs/vendor/yiisoft/yii2/helpers/BaseJson.php:61
22 | yii\helpers\BaseJson::encode(["id" => "494", "typeId" => "1", "taxCategoryId" => "1", "shippingCategoryId" => "1", ...]) Called from /var/www/myspa/htdocs/vendor/craftcms/cms/src/helpers/Db.php:127
21 | craft\helpers\Db::prepareValueForDb(["id" => "494", "typeId" => "1", "taxCategoryId" => "1", "shippingCategoryId" => "1", ...]) Called from /var/www/myspa/htdocs/vendor/craftcms/cms/src/db/ActiveRecord.php:42
20 | craft\commerce\records\LineItem::prepareForDb() Called from /var/www/myspa/htdocs/vendor/craftcms/cms/src/db/ActiveRecord.php:32
19 | craft\commerce\records\LineItem::beforeSave(false) Called from /var/www/myspa/htdocs/vendor/yiisoft/yii2/db/BaseActiveRecord.php:794
18 | craft\commerce\records\LineItem::updateInternal(null) Called from /var/www/myspa/htdocs/vendor/yiisoft/yii2/db/ActiveRecord.php:676
17 | craft\commerce\records\LineItem::update(false, null) Called from /var/www/myspa/htdocs/vendor/yiisoft/yii2/db/BaseActiveRecord.php:681
16 | craft\commerce\records\LineItem::save(false) Called from /var/www/myspa/htdocs/vendor/craftcms/commerce/src/services/LineItems.php:211
15 | craft\commerce\services\LineItems::saveLineItem(craft\commerce\models\LineItem, false) Called from /var/www/myspa/htdocs/vendor/craftcms/commerce/src/elements/Order.php:2123
14 | craft\commerce\elements\Order::_saveLineItems() Called from /var/www/myspa/htdocs/vendor/craftcms/commerce/src/elements/Order.php:967
13 | craft\services\Elements::saveElement(craft\commerce\elements\Order, false) Called from /var/www/myspa/htdocs/modules/myspa/controllers/BookingController.php:789
Maybe this belongs to the Commerce Plugin since it's a little bit more related to this but I decided to post it here because the warning is created in the Craft CMS repo.
No first world problem at all, just wanted to inform you
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported path in vendor/craftcms/cms/src/elements/db/ElementQuery.php around the deprecation warning, then trace the AssetQuery::toArray() and Yii ArrayableTrait calls shown in the stack trace. Reproduce the warning with a field whose handle is order and determine whether the behavior belongs in Craft CMS or the Commerce plugin. Done means the valid field handle no longer causes this warning without changing the deprecated element-query parameter behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100