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

Bug #1383 Duplicate vars in QUERY_STRING (_getLinksUrl() function)
Submitted: 2004-05-11 12:50 UTC
From: pauluz at gazeta dot pl Assigned: quipo
Status: Closed Package: Pager
PHP Version: Irrelevant OS:
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 : 10 - 1 = ?

 
 [2004-05-11 12:50 UTC] pauluz at gazeta dot pl
Description: ------------ compare to: Common.php,v 1.12 from CVS - lines 630 to 640 When you use 'extraVars' option in $params for Pager constructor you get a duplicate vars in QUERY_STRING generated for URL (this happend when you click "page link" at least) Solution/patch: --- Common.php 2004-01-16 12:29:20.000000000 +0100 +++ Common2.php 2004-05-11 14:12:58.000000000 +0200 @@ -623,15 +623,19 @@ class Pager_Common unset($qs[$i]); } } + // $qs contains a variables from QUERY_STRING + // and now passing 'extraVars' to it ... - foreach ($qs as $name => $value) { - $querystring[] = $name . '=' . $value; - } if (is_array($this->_extraVars)) { foreach ($this->_extraVars as $name => $value) { - $querystring[] = $name . '=' . $value; + $qs[$name] = $value; } } + // this overwrite duplicated vars + + foreach ($qs as $name => $value) { + $querystring[] = $name . '=' . $value; + } return '?' . implode('&', $querystring) . (!empty($querystring) ? '&' : '') . $this->_urlVar .'='; } Reproduce code: --------------- require_once 'Pager/Pager.php'; $itemData = array('a','b','c','d','e','f','g','h'); $params = array('mode' => 'Jumping', 'perPage' => 3, 'delta' => 5, 'itemData' => $itemData, 'extraVars' => array('special' => 'marked')); $pager = & new Pager($params); $data = $pager->getPageData(); $links = $pager->getLinks(); echo '<PRE>PAGES : ' . $links['all'] . "\n\n"; echo 'PAGED DATA: '; print_r($data); Expected result: ---------------- simple links like: script.php?special=marked&pageID=2 Actual result: -------------- when display second time there is duplicate var 'special' in QUERY_STRING script.php?special=marked&special=marked&pageID=2

Comments

 [2004-05-11 12:57 UTC] pauluz at gazeta dot pl
internal function _getLinksUrl() has been changed
 [2004-05-11 13:06 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.