Pagination in back-end breaks when filtering database result

The support for Joomla 2.5 ended on December 31, 2014. Possible bugs in Joomla 2.5 will not be patched anymore. This forum has been closed. Please update your website to Joomla 3.x

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug: https://issues.joomla.org
Locked
clongato
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sat Mar 01, 2008 6:41 pm

Pagination in back-end breaks when filtering database result

Post by clongato » Fri Mar 16, 2012 6:46 pm

I´ve noticed a weird problem in Joomla 2.5.1 backend. Whenever you filter results from the database - articles listing, redirect links listing, custom components listing - and you click to edit a record that´s not listed on page 1 (say 2 or 3) and then you return to the list view you´re redirected back to page 1 regardless the page the record you edited is.

How to make this problem happen:
1. Go to any list view.
2. Type anything in any of the filters so that the query returns more than one page of results.
3. Go to page 2.
4. Click to edit any record.
5. Click Close or Save and Close to get back to list view.
Voilà, you´re back to page 1 again.

This only happens if you´re using the filter.

Anyone knows how to fix this?

Claudio

kuloun
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Mar 28, 2012 1:49 pm

Re: Pagination in back-end breaks when filtering database re

Post by kuloun » Wed Mar 28, 2012 1:52 pm

Hi, I have exactly the same problem.

Version 1.7.1 and Version 2.5.2

kuloun
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Mar 28, 2012 1:49 pm

Re: Pagination in back-end breaks when filtering database re

Post by kuloun » Wed Mar 28, 2012 2:37 pm

I just found a temporary solution on V 1.7.1. I guess it will be similar for 2.5

file:

Code: Select all

/libraries/joomla/application/component/modellist.php
Function (around line 345):

Code: Select all

public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true)
	{
		$app = JFactory::getApplication();
		$old_state = $app->getUserState($key);
		$cur_state = (!is_null($old_state)) ? $old_state : $default;
		$new_state = JRequest::getVar($request, null, 'default', $type);

		if (($cur_state != $new_state) && ($resetPage)){
			JRequest::setVar('limitstart', 0);
		}

		// Save the new value only if it is set in this request.
		if ($new_state !== null) {
			$app->setUserState($key, $new_state);
		}
		else {
			$new_state = $cur_state;
		}

		return $new_state;
	}
Comment out :

Code: Select all

		if (($cur_state != $new_state) && ($resetPage)){
			JRequest::setVar('limitstart', 0);
		}
The result code should be:

Code: Select all

public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true)
	{
		$app = JFactory::getApplication();
		$old_state = $app->getUserState($key);
		$cur_state = (!is_null($old_state)) ? $old_state : $default;
		$new_state = JRequest::getVar($request, null, 'default', $type);

/*
This should be commented out
		if (($cur_state != $new_state) && ($resetPage)){
			JRequest::setVar('limitstart', 0);
		}
*/
		// Save the new value only if it is set in this request.
		if ($new_state !== null) {
			$app->setUserState($key, $new_state);
		}
		else {
			$new_state = $cur_state;
		}

		return $new_state;
	}
I have no idea if it will affect anything else at the moment, but it does what I need.

VisiGod
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 171
Joined: Fri Sep 02, 2005 2:26 am
Location: Portugal
Contact:

Re: Pagination in back-end breaks when filtering database re

Post by VisiGod » Wed Dec 05, 2012 6:49 pm

It seems that getUserStateFromRequest needs a new parameter in the end. You need to set resetPage to false.

Example:

$this->getUserStateFromRequest('com_xpto.filter.category_id', 'filter_category_id', 0, 'uint', false);

testcouch
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Tue Oct 27, 2009 5:27 pm

Re: Pagination in back-end breaks when filtering database re

Post by testcouch » Fri Jan 03, 2014 11:10 pm

This pagination issue is still not fixed in latest Joomla 2.5.17!:o


Locked

Return to “Joomla! 2.5 Bug Reporting”