Opened 4 years ago
Closed 3 years ago
#959 closed Defect (fixed)
navigation/pagination generates invalid urls
| Reported by: | twall | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | Core | Version: | Github Master |
| Severity: | major | Keywords: | pagination viewtype |
| Cc: | brettp | Difficulty: |
Description
If the original baseurl is something like
pg/navigation?offset=0&search_viewtype=list
then the navigation/pagination view will snip out "?offset=0", and append the new offset to the end of the URL, resulting in this:
pg/navigation&search_viewtype=list?offset=5
The one-line preg_replace on line 44 needs to be fixed:
$baseurl = preg_replace('/[\&\?]'.$word.'\=[0-9]*/',"",$varsbaseurl?
Here is one possible solution:
$baseurl = preg_replace('/[\&]'.$word.'\=[0-9]*/',"",$varsbaseurl?);
$baseurl = preg_replace('/[\?]'.$word.'\=[0-9]*[\&]/',"?",$baseurl);
$baseurl = preg_replace('/[\?]'.$word.'\=[0-9]*$/',"",$baseurl);
NOTE: there is likely an identical issue with navigation/viewtype.php
Change History (2)
comment:1 Changed 4 years ago by cash
- Type changed from unconfirmed defect to confirmed defect
- Version changed from 1.5 to SVN Trunk
comment:2 Changed 3 years ago by brettp
- Resolution set to fixed
- Status changed from new to closed
(In [svn:3866]) Fixes #959: Added elgg_http_remove_url_query_element() to remove a GET element instead of using faulty regexp.

An easy test for this is to create 11 blogs on a test site and then on the all site blog listing add a test parameter on the url like this: /mod/blog/everyone.php?offset=10&test=1
As described above the problem is this code:
$baseurl = preg_replace('/[\&\?]'.$word.'\=[0-9]*/',"",$vars['baseurl']);This line is used in 5 places:
If there is a good reason to have this in 5 different files, it should be pulled out into a function (while adding more logic to fix the bug).