From 5cf9bdb5ae79878c7d1716754397e0ad383216b7 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 14 Apr 2005 04:24:22 +0000 Subject: [PATCH] Fix post paging regex to avoid regex collision between posts with slugs that differ only by a trailing number. http://mosquito.wordpress.org/view.php?id=1235 git-svn-id: https://develop.svn.wordpress.org/trunk@2535 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/classes.php | 8 +++++++- wp-includes/functions.php | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wp-includes/classes.php b/wp-includes/classes.php index fa8bffc2d0..f946300d1a 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -253,6 +253,11 @@ class WP_Query { $q['posts_per_page'] = get_settings('posts_per_rss'); $q['what_to_show'] = 'posts'; } + + if (isset($q['page'])) { + $q['page'] = trim($q['page'], '/'); + $q['page'] = (int) $q['page']; + } $add_hours = intval(get_settings('gmt_offset')); $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); @@ -1123,7 +1128,8 @@ class WP_Rewrite { $post = 1; $trackbackmatch = $match . $trackbackregex; $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; - $match = $match . '?([0-9]+)?/?$'; + $match = rtrim($match, '/'); + $match = $match . '(/[0-9]+)?/?$'; $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1); } else { $match .= '?$'; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 2f017a5149..8c192971d5 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -879,9 +879,10 @@ function setup_postdata($post) { $day = mysql2date('d.m.y', $post->post_date); $currentmonth = mysql2date('m', $post->post_date); $numpages = 1; + $page = get_query_var('page'); if (!$page) $page = 1; - if (isset($p)) + if (is_single() || is_page()) $more = 1; $content = $post->post_content; if (preg_match('//', $content)) {