No Code Attached Yet bug
avatar Irata
Irata
19 Jun 2023

Steps to reproduce the issue

  1. Add this code to a list HtmlView class.
// Flag indicates to not add limitstart=0 to URL
   $this->pagination->hideEmptyLimitstart = true;
  1. In the Model have just the default populateState or no populateState method at all so that is falls through to the populateState of the ListModel class.
class MyModel extends ListModel
{
....
	protected function populateState($ordering = 'description', $direction = 'ASC')
    {
        // List state information.
        parent::populateState($ordering, $direction); 
    }
  1. 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.

  2. Select a page other than the 1st page and you should see a &limitstart=nn or &start=in the url

  3. 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.

Expected result

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.

Actual result

When selecting the 1st page you are returned to the current page that you are on.

System information (as much as possible)

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.

Additional comments

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.

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
3.00

avatar Irata Irata - open - 19 Jun 2023
avatar Irata Irata - change - 19 Jun 2023
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 19 Jun 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Jun 2023
avatar Hackwar Hackwar - change - 28 Mar 2024
Labels Added: bug
avatar Hackwar Hackwar - labeled - 28 Mar 2024

Add a Comment

Login with GitHub to post a comment