// Flag indicates to not add limitstart=0 to URL
$this->pagination->hideEmptyLimitstart = true;
class MyModel extends ListModel
{
....
protected function populateState($ordering = 'description', $direction = 'ASC')
{
// List state information.
parent::populateState($ordering, $direction);
}
In the components front end go to List and make sure you have enough items available to have two or more pages of records to select from in the default pagination displayed.
Select a page other than the 1st page and you should see a &limitstart=nn or &start=in the url
Now select the 1st page and you will see you are returned to the same page you were previously on. Selecting any other page will work as expected , you just can't get back to the first page.
I would expect to be able to select the 1st page of records in the pagination and not see the &limitstart= or &start= field in the url.
When selecting the 1st page you are returned to the current page that you are on.
The issue appears to come from a logic issue at this point in the populateState method of the ListModel, https://github.com/joomla/joomla-cms/blob/4efb93654c56ce5b173cd56254d12559cd3c5896/libraries/src/MVC/Model/ListModel.php#L615-617
$value = $app->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0, 'int');
$limitstart = ($limit != 0 ? (floor($value / $limit) * $limit) : 0);
$this->setState('list.start', $limitstart);
Once the &limitstart=0 is removed from the 1st page as per the flag set in the View then when we arrive at line #616 there is no $limitstart in the url and $value is not set to zero as you might expect but it has the limitstart last stored, i.e. the &limitstart for the current page.
With the flag set to false then the &limitstart is set in the url and the $value is set to zero which is as expected.
Why this doesn't show up in the core components that use this flag, which is a lot of them, is that they have this piece of code in their Models populateState method that replaces the faulty behaviour and assigns a zero to the &limitstart used by the Model sql.
// List state information
$limitstart = $this->input->getUint('limitstart', 0);
$this->setState('list.start', $limitstart);
The issue appears to have been in play since 3.9 when this change was made, https://issues.joomla.org/tracker/joomla-cms/19467 and is still there in 4.3 code.
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
bug
|