diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index c9a7c2cfeca..25b069c3056 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -1,5 +1,10 @@ # Release Notes for Craft CMS 3.x +## Unreleased + +### Fixed +- Fixed a bug where the `orderBy` element query param wasn’t being respected when used in conjunction with a `with` param to eager-load elements in a specific order. ([#3109](https://github.com/craftcms/cms/issues/3109)) + ## 3.0.16 - 2018-07-17 ### Added diff --git a/src/services/Elements.php b/src/services/Elements.php index f7dc8285b54..b113e334045 100644 --- a/src/services/Elements.php +++ b/src/services/Elements.php @@ -1206,7 +1206,10 @@ public function eagerLoadElements(string $elementType, array $elements, $with) $targetPath = $sourcePath . '.' . $segment; // Figure out the path mapping wants a custom order - $useCustomOrder = !empty($pathCriterias[$targetPath]['order']); + $useCustomOrder = ( + !empty($pathCriterias[$targetPath]['orderBy']) || + !empty($pathCriterias[$targetPath]['order']) + ); // Make sure we haven't already eager-loaded this target path if (!isset($elementsByPath[$targetPath])) {