Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.1

Bug #1904 Pager drops GET values although append = true
Submitted: 2004-07-17 16:00 UTC
From: listen at scroogie dot de Assigned: quipo
Status: Closed Package: Pager
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2004-07-17 16:00 UTC] listen at scroogie dot de
Description: ------------ The append-option will not carry on Array Values given as GET Parameters. The code in common.php just overwrites the same array-element with the different values, resulting in having just the last value saved. Possible solution could look like this: function _getLinksUrl() { // Sort out query string to prevent messy urls $querystring = array(); $qs = array(); if (!empty($_SERVER['QUERY_STRING'])) { $qs = explode('&', str_replace('&', '&', $_SERVER['QUERY_STRING'])); for ($i = 0, $cnt = count($qs); $i < $cnt; $i++) { if(strstr($qs[$i], '=') !== false){ // check first if exist a pair list($name, $value) = explode('=', $qs[$i]); if ($name != $this->_urlVar) { if (isset($qs[$name])) { if (is_array($qs[$name])) { $qs[$name][] = $value; } else { $qs[$name] = array($qs[$name], $value); } } else { $qs[$name] = $value; } } } else { $qs[$qs[$i]] = ''; } unset($qs[$i]); } } foreach ($qs as $name => $value) { if (is_array($value)) { foreach ($value as $v) { $querystring[] = $name . '=' . $v; } } else { $querystring[] = $name . '=' . $value; } } if (is_array($this->_extraVars)) { foreach ($this->_extraVars as $name => $value) { $querystring[] = $name . '=' . $value; } } return '?' . implode('&', $querystring) . (!empty($querystring) ? '&' : '') . $this->_urlVar .'='; } Reproduce code: --------------- Just set the append option to true in the options array passed to the constructor, and try passing an array like site.php?foo[]=1&foo[]=2&foo[]=3 Pager will just pass foo[]=3 to the next page. Code-Change is necessary in common.php in method _getLinksUrl().

Comments

 [2004-07-18 07:42 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2004-07-18 11:12 UTC] listen at scroogie dot de
Patch works perfectly in my case. Thanks for the quick fix, keep up the good work