mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Don't allow negative values when paging. fixes #2893
git-svn-id: http://svn.automattic.com/wordpress/trunk@3957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
00b5713e5d
commit
8475c636a1
@ -555,6 +555,7 @@ class WP_Query {
|
||||
if (isset($q['page'])) {
|
||||
$q['page'] = trim($q['page'], '/');
|
||||
$q['page'] = (int) $q['page'];
|
||||
$q['page'] = abs($q['page']);
|
||||
}
|
||||
|
||||
$add_hours = intval(get_settings('gmt_offset'));
|
||||
@ -875,18 +876,19 @@ class WP_Query {
|
||||
|
||||
// Paging
|
||||
if (empty($q['nopaging']) && ! $this->is_single && ! $this->is_page) {
|
||||
$page = $q['paged'];
|
||||
$page = abs(intval($q['paged']));
|
||||
if (empty($page)) {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (($q['what_to_show'] == 'posts')) {
|
||||
$q['offset'] = abs(intval($q['offset']));
|
||||
if ( empty($q['offset']) ) {
|
||||
$pgstrt = '';
|
||||
$pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
|
||||
$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
|
||||
} else { // we're ignoring $page and using 'offset'
|
||||
$pgstrt = intval($q['offset']) . ', ';
|
||||
$pgstrt = $q['offset'] . ', ';
|
||||
$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
|
||||
}
|
||||
} elseif ($q['what_to_show'] == 'days') {
|
||||
|
Loading…
Reference in New Issue
Block a user