Make WordPress Core

Opened 12 years ago

Closed 10 years ago

#25273 closed defect (bug) (fixed)

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

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

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 12 years ago.

Download all attachments as: .zip

Change History (8)

@betzster
12 years ago

#1 @SergeyBiryukov
12 years ago

  • Component changed from General to Template

#2 @nacin
12 years ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added

#3 follow-up: @jessepollak
12 years ago

  • Keywords 2nd-opinion has-patch added
  • Severity changed from normal to trivial
  • Version set to 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
12 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
12 years ago

  • Version changed from trunk to 0.71

#6 @wonderboymusic
10 years ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to 4.4

#7 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to 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.