?
avatar AndySDH
AndySDH
21 Feb 2017

I found out about this in an odd way. Please note that the plugins listed below are just used as examples to reveal the underlying issue.

I installed a plugin that picks an image from the article currently displayed and adds it to head of the document as og:image.
Somehow, someway, the plugin picks up an image from an article even in the Category (Blog/List) View... despite all Menu settings are set to display 0 articles. Now this would make sense if there were articles set to be displayed, but Leading Articles, Intro Articles and Links are all set to 0, and it still picks up the image from an article that would be there in Category View if any number of articles would be set to be displayed, but they are not. There is no presence of said image in the body of the document (because articles are not displayed!) but somehow the plugin can get to it and add it to the head.

And then the same problem emerged thanks to another plugin, "Simple Redirect Plugin", which allows you to add meta refresh redirect to the head of the document when an article is loaded by writing a string in the text of the article.
Again, in Category View, with all article settings set to 0 (Leading Articles, Intro Articles and Links are all set to 0), something even worse is revealed. The plugin puts in the head the meta refresh redirect links of ALL THE ARTICLES in that Category! Instead, if you set any of the display article settings to a certain number (like, 1 Intro Article), it will pick up only the respective amount of article redirects (in this case, 1), so this works as expected. But if you put everything to 0, it somehow can get to all of them.

Those two evidences must mean that Joomla secretly gets/loads the data (including text) of all the articles included in the Category even when 0 articles are set to be displayed, and 0 are actually displayed, but their data is clearly loaded in the background.

Steps to reproduce the issue

  • Install "Simple Redirect Plugin", this is just a plugin that can add something to the head of the document, it could be any other that does a similar thing
  • I suggest setting the plugin to "open redirect in a new window" to avoid it redirecting you away from the Category page
  • Create a few articles in a Category where you set up redirect in all of them using the above plugin tags
  • Create a Menu Item for that Category but set Leading Articles, Intro Articles and Links all set to 0 (zero)

Expected result

  • In the frontend, no articles will be displayed, and nothing from the articles will be loaded, so there is no way the plugin can "see/get" anything from the text of the article.

Actual result

  • In the frontend, no articles will be actually displayed (as intended), but the meta refresh data from all the articles will be still loaded in the head of the page (literally all the articles! if there are 300 articles that have a redirect set in a category, 300 meta refresh lines will be loaded!)

System information (as much as possible)

Database Version 5.5.54-38.6-log
Database Collation utf8_general_ci
Database Connection Collation utf8mb4_general_ci
PHP Version 5.6.30
Web Server Apache
WebServer to PHP Interface cgi-fcgi
Joomla! Version Joomla! 3.6.5 Stable [ Noether ] 1-December-2016 22:46 GMT
Joomla! Platform Version Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
User Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0

Additional comments

This also happens with the default Protostar template.

In addition, if you do a template override and you remove the introtext from articles in the Category View, this should stop the plugin from getting the data even when you set Article Display options to a certain number (not 0), because the Introtext is not actually loaded, so how can a plugin get to the text of the article and load whatever it is that it loads?
So, in addition to checking why articles data is loaded by Joomla in the background in Category View even when all article settings are set to 0, you should also check why articles text data is loaded in the background even when introtext is removed from the View with a template override.

avatar AndySDH AndySDH - open - 21 Feb 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Feb 2017
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - edited - 21 Feb 2017
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - edited - 21 Feb 2017
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - edited - 21 Feb 2017
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - edited - 21 Feb 2017
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - edited - 21 Feb 2017
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar AndySDH AndySDH - edited - 21 Feb 2017
avatar AndySDH AndySDH - change - 21 Feb 2017
The description was changed
avatar mbabker
mbabker - comment - 21 Feb 2017

if you do a template override and you remove the introtext from articles in the Category View, this should stop the plugin from getting the data even when you set Article Display options to a certain number (not 0), because the Introtext is not actually loaded, so how can a plugin get to the text of the article and load whatever it is that it loads?

That's not exactly how things work. The data gets loaded first by the view class, then the resulting dataset is processed through the plugin events, then the view renders that data object. So just because something is not displayed in the view does not mean that it is inherently removed from the query's field list or available fields in plugins.

avatar AndySDH
AndySDH - comment - 21 Feb 2017

@mbabker Oh I understand. Although, did it work like that in older Joomlas too? I'm pretty sure for example in Joomla 1.5, if I were to remove the introtext from the Blog View this problem wasn't happening and plugins couldn't get to it. I think this would be a behavior that would make sense. Also I'm wondering, does this impact performance? Why load and require data that it's not going to be displayed or needed? I assume the plugin has to go through the text of all the articles displayed on that page despite the text not being shown. Would this render the fact that I'm not showing the text "useless" performance-wise?

Also I tried something else, I tried to completely erase the content of the "blog.php" page just to see what would happen, and despite that, the plugin STILL can get to the data. How?

Anyways, apart from that, the issue when 0 articles are set is still valid.
Because when the number of articles is specified, it only loads data from the number of articles specified (say, if you set 6 articles per page, it loads data from 6 articles per page).
But when all articles option are set to 0, it loads data from ALL articles in that category. This can't be the expected behavior, it should surely NOT load data in this scenario, right?

Thanks for the support.

avatar Fedik
Fedik - comment - 21 Feb 2017

old trick set it to -1 ?

avatar AndySDH
AndySDH - comment - 21 Feb 2017

@Fedik Well, assuming that works, I don't think I should be having to do that... 0 means 0.
It shows 0 articles, but it loads the data from All of them? That's not consistent.

avatar mbabker
mbabker - comment - 21 Feb 2017

The models that query the information aren't aware of what data is or is not displayed in your layout. Remember the models are supposed to be reusable so locking them to a layout's fields wouldn't be a good behavior. Likewise, to render a view it would mean we'd have to parse the layout files, figure out what variable represents the data object the model is supposed to use, extract all the field names from that, and build the appropriate SELECT clause for the query (with no information on relations or field aliases); not efficient by any means.

The order is data is queried, plugins are triggered, THEN the layout is assembled. Nothing before the layout step is aware of what's in the layout, so the plugins run solely based on the data object returned by the query and a given context. If the logic were something like layout built then plugins run what you're saying would make sense but at that point the plugins would be manipulating your assembled HTML versus a raw object with the data readily available.

As for the 0 thing, honestly my suggestion is there is something in the model to disallow a 0 query and it converts it to a query with no limit. I'd also suggest allowing a 0 limit might break stuff so I don't know if I'd make a change for that use case.

avatar AndySDH
AndySDH - comment - 21 Feb 2017

@mbabker Thanks for the thorough explanation. Everything is clear now.
However, I do believe the occurrence where 0 articles are set to be displayed should be addressed, isn't it weird that the query does allow to display 0 articles if you set that, but not to load 0 data in that scenario?
I don't envision how it could break stuff as it would apply only to this specific scenario.

Btw, I tried the -1 trick suggested above by @Fedik and it worked.

avatar Fedik
Fedik - comment - 21 Feb 2017

.. there is something in the model to disallow a 0 query and it converts it to a query with no limit..

I think 0 made for allow to reset the pagination limit, to allow to display "All" (unlimited)

avatar AndySDH
AndySDH - comment - 27 Feb 2017

After further testing, this should really be addressed. Even when no plugin needs to load anything, it's clear that Joomla still loads ALL the articles data when the option is set to 0, because if we're talking about a category which contains hundreds of articles, the loading of the category blog page (with 0 articles set to display) is VERY SLOW. It takes dozens of seconds. This literally makes no sense.
How can the loading of a category blog page be slower when you display ZERO articles (because it loads data for all of them, even hundreds, or thousands, all of them in the background, but you're displaying zero) then when you're displaying 20 articles (because it correctly loads just those 20).
This can't be intended behavior.
I understand the "-1" solution and I guess I will adopt that, but it sounds/looks like a workaround and I don't think you should be having to work around such an issue... Actually it's pretty strange that nobody noticed it before. I guess it might be because not many people display 0 articles (I do it because sometimes I load articles by other means (plugin/modules) by loading them in the category description), but I don't think that means it shouldn't be supported correctly. I'm 100% sure this wasn't an issue in Joomla 1.5.

avatar joomla-cms-bot joomla-cms-bot - change - 27 Feb 2017
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 27 Feb 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Apr 2017
Priority Medium Low
Status New Needs Review
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Apr 2017

set Status on "Needs Review" in Issue Tracker.


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

avatar AndySDH
AndySDH - comment - 26 Jul 2017

After further testing, this should really be addressed. Even when no plugin needs to load anything, it's clear that Joomla still loads ALL the articles data when the option is set to 0, because if we're talking about a category which contains hundreds of articles, the loading of the category blog page (with 0 articles set to display) is VERY SLOW. It takes dozens of seconds. This literally makes no sense.
How can the loading of a category blog page be slower when you display ZERO articles (because it loads data for all of them, even hundreds, or thousands, all of them in the background, but you're displaying zero) then when you're displaying 20 articles (because it correctly loads just those 20).
This can't be intended behavior.
I understand the "-1" solution and I guess I will adopt that, but it sounds/looks like a workaround and I don't think you should be having to work around such an issue... Actually it's pretty strange that nobody noticed it before. I guess it might be because not many people display 0 articles (I do it because sometimes I load articles by other means (plugin/modules) by loading them in the category description), but I don't think that means it shouldn't be supported correctly. I'm 100% sure this wasn't an issue in Joomla 1.5.

Hello, has this issue been considered?

avatar AndySDH AndySDH - change - 8 Nov 2017
Status Needs Review Closed
Closed_Date 0000-00-00 00:00:00 2017-11-08 10:46:06
Closed_By AndySDH
avatar AndySDH AndySDH - close - 8 Nov 2017

Add a Comment

Login with GitHub to post a comment