? ? Pending

User tests: Successful: Unsuccessful:

avatar socke300
socke300
25 Aug 2021

Introduction

When creating PR #35341, we noticed that the _getListCount(Query) of DataBaseModel.php did not clear the order of the query in the second if-statement. Because it is not important for a count function in which order the results are placed and could represent a performance problem in the future when using other queries, so we have added the clear function.

Summary of Changes

In the method _getListCount(Query) of DataBaseModel.php the order was also cleared in the second if-statement.

Testing Instructions

  1. Install Joomla 4.0
  2. Install Sample Data
  3. Activate the Debug Tool System -> Global Config -> Debug System on
  4. Open the Smart Search
  5. Search for a word
  6. For example, look for the query as in Actual result BEFORE applying this Pull Request
  7. Repeat the steps with this PR

Actual result BEFORE applying this Pull Request

Search Query contains an Order BY.

SELECT l.link_id, l.object,SUM(m.weight) AS ordering
FROM kaftq_finder_links AS l
INNER JOIN `kaftq_finder_links_terms` AS m ON m.link_id = l.link_id
WHERE `l`.`access` IN (:preparedArray1,:preparedArray2,:preparedArray3) AND l.state = 1 AND l.published = 1 AND (l.publish_start_date IS NULL OR l.publish_start_date <= '2021-08-25 08:24:00') AND (l.publish_end_date IS NULL OR l.publish_end_date >= '2021-08-25 08:24:00') AND m.term_id IN (11)
GROUP BY l.link_id,l.object
HAVING SUM(CASE WHEN m.term_id IN (11) THEN 1 ELSE 0 END) > 0
ORDER BY ordering DESC

Expected result AFTER applying this Pull Request

Search Query no longer contains an Order BY.

SELECT l.link_id, l.object,SUM(m.weight) AS ordering
FROM kaftq_finder_links AS l
INNER JOIN `kaftq_finder_links_terms` AS m ON m.link_id = l.link_id
WHERE `l`.`access` IN (:preparedArray1,:preparedArray2,:preparedArray3) AND l.state = 1 AND l.published = 1 AND (l.publish_start_date IS NULL OR l.publish_start_date <= '2021-08-25 08:23:00') AND (l.publish_end_date IS NULL OR l.publish_end_date >= '2021-08-25 08:23:00') AND m.term_id IN (11)
GROUP BY l.link_id,l.object
HAVING SUM(CASE WHEN m.term_id IN (11) THEN 1 ELSE 0 END) > 0

Documentation Changes Required

Probably not.

Contributers

@scout507 @Waleet

avatar socke300 socke300 - open - 25 Aug 2021
avatar socke300 socke300 - change - 25 Aug 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Aug 2021
Category Libraries
avatar richard67
richard67 - comment - 25 Aug 2021

@socke300 Maybe you should also change the comment in line 181 to reflect your change?

// Remove the limit and offset part if it's a DatabaseQuery object

avatar socke300 socke300 - change - 25 Aug 2021
Labels Added: ?
avatar socke300
socke300 - comment - 25 Aug 2021

@richard67 Thanks for the feedback, comment has been added.

avatar richard67
richard67 - comment - 25 Aug 2021

@socke300 I meant to extend the comment by your change so that the previously available information in that comment is not lost.

I.e. change
// Remove the limit and offset part if it's a DatabaseQuery object
to something like
// Remove the limit, offset and order parts if it's a DatabaseQuery object

But like you have done it now it only mentions the order part.

avatar socke300
socke300 - comment - 25 Aug 2021

@richard67 Oh, I get it now, should I change it to // Remove the limit, offset and order parts if it's a DatabaseQuery object and remove the comment underneath?

avatar richard67
richard67 - comment - 25 Aug 2021

@richard67 Oh, I get it now, should I change it to // Remove the limit, offset and order parts if it's a DatabaseQuery object and remove the comment underneath?

@socke300 Yes.

avatar richard67 richard67 - test_item - 25 Aug 2021 - Tested successfully
avatar richard67
richard67 - comment - 25 Aug 2021

I have tested this item successfully on a20207d


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35362.

avatar richard67
richard67 - comment - 25 Aug 2021

Hint for other testers: There are 2 very similar queries. The first one with limit and ordering, and the second one without limit. This PR here fixes the 2nd one so it also has no ordering. @alikon Could you test this one here?

avatar alikon
alikon - comment - 26 Aug 2021

shouldn't this to be backported to 3.10 ?

avatar alikon alikon - test_item - 26 Aug 2021 - Tested successfully
avatar alikon
alikon - comment - 26 Aug 2021

I have tested this item successfully on a20207d


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35362.

avatar alikon alikon - change - 26 Aug 2021
Status Pending Ready to Commit
avatar alikon
alikon - comment - 26 Aug 2021

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35362.

avatar alikon
alikon - comment - 26 Aug 2021

for 3.10 see #35383

avatar bembelimen bembelimen - close - 26 Aug 2021
avatar bembelimen bembelimen - merge - 26 Aug 2021
avatar bembelimen bembelimen - change - 26 Aug 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-08-26 10:58:57
Closed_By bembelimen
Labels Added: ?
avatar bembelimen
bembelimen - comment - 26 Aug 2021

Thanks

Add a Comment

Login with GitHub to post a comment