How the “getAuthors” Function Slows Down the Joomla Backend “Articles” Page

Note: The solution in this post is a core modification. Proceed with caution.

Another note: This post has been modified on January 31st, 2018 to correct an error. The post has originally been published the day before, on January 30th, 2018.

While analyzing the performance of the backend of a Joomla 3.8 website that has over 200K articles, we noticed something interesting; we noticed that the following query was taking some time:

SELECT u.id AS value, u.name AS text
FROM #__users AS u
INNER JOIN #__content AS c ON c.created_by = u.id
GROUP BY u.id, u.name
ORDER BY u.name;

The above query generates a list of all the users who have created at least one article. It was taking about 14 seconds and it was examining about 500,000 rows. Tracing the query, we discovered that it was triggered by the getAuthors function which is located in the articles.php file (which is in turn located under the administrator/components/com_content/models folder).

So, which page triggers the “getAuthors” function?

Mainly it is the Articles page (under Content -> Articles) that triggers the getAuthors function. At first, we thought that it does that to populate the Select Author filtering dropdown (under the Search Tools), so, when someone is searching for an author, they won’t have to search through the users that don’t have any articles published. However, on closer look, we discovered that this wasn’t the case. The function getAuthors had no use, it was just loaded by the administrator articles view (the file articles.php which is located under the folder administrator/components/com_content/views) by the following line:

$this->authors = $this->get('Authors');

Now we searched the whole Joomla website for a single usage of this function, but we couldn’t find any. Yes, the function was utterly useless. So, we just added return array(); to the very beginning of the getAuthors function and we got rid of that heavy and unnecessary query.

We hope that you enjoyed this light post and that you found it useful. If you need help with the implementation, then just contact us. Our fees are right, our work is clean, and we are experts in optimizing Joomla websites.

No comments yet.

Leave a comment