User tests: Successful: Unsuccessful:
Pull Request for Issue #18529 and #32612 .
This PR proposes a solution to fix the two issues #18529 and #32612. Basically, it now will only load articles if limit > 0 (users want to display articles using the category layout)
See #18529 and #32612 to understand the actual issue. However, this PR has a backward incompatible change, so I'm unsure if it should be accepted (especially for staging).
Please note that there is a backward incompatible changes here then the site has no menu item to link to one of the three menu item types (basically, no suitable menu item could be found to link to a category)
For example, when you unpublish all menu items (keep home menu but links to a different component than com_content) and access to a category display in Articles - Categories. Before this PR, it will display all articles from that category, after this PR, only number of articles will be displayed (controlled by Default List Limit parameter in Global Configuration)
Status | New | ⇒ | Pending |
Category | ⇒ | Front End com_content |
@joomdonation should we return empty array at category model when $limit == 0
?
or return empty array on ListModel.php
, because this issue can affect other core components.
Should we return empty array at category model when
$limit == 0
?
I have to look at it again but I think it is working like that for category model at the moment
return empty array on ListModel.php, because this issue can affect other core components
It is a backward-incompatible change, so we are not allowed to do that. Further more, in Joomla!, look like we want all records returned when no limit is set.
I think we only need change line 251 of components\com_content\models\category.php
from if ($limit >= 0)
to if ($limit > 0)
Labels |
Added:
?
|
I think we only need change line 251 of
components\com_content\models\category.php
from
if ($limit >= 0)
to
if ($limit > 0)
I don't think that's enough. It will cause no articles being displayed when access to a category from Articles - Categories module (with no menu items linked to categories or category view). Also, if we just change that, there are still unnecessary code executed ($model->setState commands) when we do not need to query database to get articles.
I will try to review code carefully later.
Correct me if i'm wrong. Your code is trying to resolve unlimited items on two cases:
index.php?option=com_content&view=category&id={category_id}
list_limit
// Set limit for query. If list, use parameter. If blog, add blog parameters for limit.
if (($app->input->get('layout') === 'blog') || $params->get('layout_type') === 'blog')
- Exactly, Category Blog has default settings, so it should fall back to that:
And if this was not the case, I don't think this is a "BC Change", this is a "Bug Fix" :D
I've found a mistake at my point. That you can change layout of category itself to Listing
. In this case, the limit should be global config list_limit
as @joomdonation did :).
But if category layout is blog
, the limit should respect blog global config, otherwise the pagination will be wrong.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-04-26 04:34:12 |
Closed_By | ⇒ | joomdonation | |
Labels |
Added:
?
|
Why was this PR closed, @joomdonation @Quy ?
This is still an issue in Joomla 4.
Thanks for the effort!
Unfortunately, I tested this unsuccessfully. This results in this error when viewing a category with 0 articles displayed:
0 - Call to a member function getPagination() on null