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  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 7 + 39 = ?

 
 [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] quipo
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. -- I committed a fix to the CVS repository. I didn't use your patch since it caused the nasty side effect of duplicating non-array querystring parameters at each page transition. Please let me know if everything is ok, then I'll roll out a new release. Many thanks for the report.
 [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