Make WordPress Core

Opened 13 years ago

Closed 11 years ago

#25273 closed defect (bug) (fixed)

wp_link_pages shouldn't be able to use a negative page number

Reported by: betzster Owned by: wonderboymusic
Priority: normal Milestone: 4.4
Component: Posts, Post Types Version: 0.71
Severity: trivial Keywords: has-patch
Cc: Focuses: template

Description

Even though the page number shouldn't be able to get to negative anyway, it would still be good to check and not allow the previous link to go to -1.

Attachments (1)

25273.patch​ (520 bytes ) - added by betzster 13 years ago.

Download all attachments as: .zip

Change History (8)

@betzster
13 years ago

#1 @SergeyBiryukov
13 years ago

  • Component General → Template

#2 @nacin
13 years ago

  • Component Template → Posts, Post Types
  • Focuses template added

#3 follow-up: @jessepollak
13 years ago

  • Keywords 2nd-opinion has-patch added
  • Severity normal → trivial
  • Version → trunk

Thanks for the bug report betzser, sorry it didn't get a faster response!

This issue is still around in trunk revision 27076.

To recreate the issue, run inside of The Loop:

global  $multipage, $page, $more;
$multipage = true;
$page = 0;
$more = true;

wp_link_pages(array('next_or_number' => 'next'));

This creates "Previous page" links where the link goes to a page with the index -1.

The only situation where this is an issue is when the $page ID <= 0, which I'm not sure ever really happens. That said, it's a tiny fix, so it may be worth just merging in because why not.

I'll defer to the core team to decide whether the existing patch should be accepted.

Thanks again for the report betzster!

#4 in reply to: ↑ 3 @betzster
13 years ago

Replying to jessepollak:

The only situation where this is an issue is when the $page ID <= 0, which I'm not sure ever really happens.

I saw this on a live site, though I don't remember the details anymore.

#5 @SergeyBiryukov
13 years ago

  • Version trunk → 0.71

#6 @wonderboymusic
11 years ago

  • Keywords 2nd-opinion removed
  • Milestone Awaiting Review → 4.4

#7 @wonderboymusic
11 years ago

  • Owner set to wonderboymusic
  • Resolution → fixed
  • Status new → closed

In 34108:

In wp_link_pages(), ensure that $prev is greater than 0.

Props betzster.
Fixes #25273.

Note: See TracTickets for help on using tickets.