Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Pagination bug fix #2012

Closed
wants to merge 3 commits into from

2 participants

@tocaibiza

If "reuse_query_string" is true, lib wasn't checking if there is already a "?" sign in url.

Also, a check for empty get array was missing.

@tocaibiza tocaibiza Pagination bug fix
If "reuse_query_string" is true, lib wasn't checking if there is already a "?" sign in url.

Also, a check for empty get array was missing.
ad80b75
system/libraries/Pagination.php
@@ -460,13 +460,14 @@ public function create_links()
// Unset the controll, method, old-school routing options
unset($get['c'], $get['m'], $get[$this->query_string_segment]);
- if ( ! $get) $get = array();
-
- // Put everything else onto the end
- $query_string = (strpos($this->base_url, '&') !== FALSE ? '&' : '?') . http_build_query($get, '', '&');
+ if (is_array($get) AND ! empty($get))
@narfbg Owner
narfbg added a note

Style guide says that && should be used instead of AND. However, after 77bd21b, you'll only need to have the ! empty($get) check here.

Also, please change the file permissions back to 644. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Dimitar added some commits
@narfbg
Owner

Closing, #2016 is identical.

@narfbg narfbg closed this
@nonchip nonchip referenced this pull request from a commit in nonchip/CodeIgniter
@narfbg narfbg Manually apply a fix submitted via PR #2012, #2016 926b304
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 20, 2012
  1. @tocaibiza

    Pagination bug fix

    tocaibiza authored
    If "reuse_query_string" is true, lib wasn't checking if there is already a "?" sign in url.
    
    Also, a check for empty get array was missing.
  2. Another bug fix in Pagination

    Dimitar authored
    Suffix wasn't added to first url.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 7 deletions.
  1. +8 −7 system/libraries/Pagination.php
View
15 system/libraries/Pagination.php 100644 → 100755
@@ -460,19 +460,20 @@ public function create_links()
// Unset the controll, method, old-school routing options
unset($get['c'], $get['m'], $get[$this->query_string_segment]);
- if ( ! $get) $get = array();
-
- // Put everything else onto the end
- $query_string = (strpos($this->base_url, '&') !== FALSE ? '&' : '?') . http_build_query($get, '', '&');
+ if ( ! empty($get))
+ {
+ // Put everything else onto the end
+ $query_string = (strpos($this->base_url, '?') !== FALSE ? '&' : '?') . http_build_query($get, '', '&');
- // Add this after the suffix to put it into more links easily
- $this->suffix .= $query_string;
+ // Add this after the suffix to put it into more links easily
+ $this->suffix .= $query_string;
+ }
}
// Render the "First" link
if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1))
{
- $first_url = ($this->first_url === '') ? $this->base_url : $this->first_url;
+ $first_url = ($this->first_url === '') ? $this->prefix.$this->base_url.$this->suffix : $this->first_url;
// Take the general parameters, and squeeze this pagination-page attr in there for JS fw's
$attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, 1);
Something went wrong with that request. Please try again.