From 776f60be302526135fcbe96d67ead4ef67041d3c Mon Sep 17 00:00:00 2001 From: Jaanus Nurmoja Date: Fri, 14 Jan 2022 13:22:26 +0200 Subject: [PATCH] Fix for case when table joins, although created by their "logical" order, have wrong order in final queries Actually it would make more sense if we create a feature of reordering joins. example of issue from one to two from two to three from three to four from four to five it could produce joins in this order left join two on two.one_id= one.id left join three on three.two_id= two.id left join five on five.four_id = four.id left join four on four.three_id = three.id and error message which says that there is no four.id in field list --- components/com_fabrik/models/list.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/com_fabrik/models/list.php b/components/com_fabrik/models/list.php index dec9e75ce3b..4fa731f2284 100644 --- a/components/com_fabrik/models/list.php +++ b/components/com_fabrik/models/list.php @@ -3234,6 +3234,9 @@ public function buildQueryJoin($query = false) $return = array(); $joins = ($this->get('includeCddInJoin', true) === false) ? $this->getJoinsNoCdd() : $this->getJoins(); + $id = array_column( $joins, "id" ); + array_multisort( $id, SORT_ASC, $joins ); + foreach ($joins as $join) { // Used to bypass user joins if the table connect isnt the Joomla connection