[wp-trac] [WordPress Trac] #16746: post paginating <!--nextpage--> does not work
WordPress Trac
noreply at wordpress.org
Wed Mar 13 02:24:17 UTC 2013
#16746: post paginating <!--nextpage--> does not work
--------------------------+-----------------------
Reporter: hakre | Owner: nacin
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 3.6
Component: Query | Version:
Severity: normal | Resolution:
Keywords: needs-patch |
--------------------------+-----------------------
Changes (by nacin):
* keywords: has-patch commit => needs-patch
Comment:
I did understand the initial report here, and based on my original
understanding of the surrounding code, I did not think this patch should
be applied. Basically, if someone had `<!--nextpage-->` at the start of a
post, and then later in the post, they'd currently have two pages. With
this patch, they would have three — including an empty first page. This is
not expected and is fairly lame. While a "page break" usually means to
immediately start a new page, `<!--nextpage-->` just as much marks the
start of a page, and if a user was using it to mark the start of page 1
(and it worked) then they should not be punished. I also assumed, knowing
the age of this code, that this check existed since b2.
However, in this case, I was wrong. While this code is from b2,
[http://core.trac.wordpress.org/browser/trunk/b2-include/b2template.functions.php?rev=20#L1237
b2 used a preg_match] that *did* obey `<!--nextpage-->` at the start of a
string. It was changed to strpos() in [8754], for performance but it also
changed the functionality.
Additionally, this is check is to decide whether there is pagination at
all. If the post starts with `<!--nextpage-->`, strpos() will return 0,
and no other `<!--nextpage-->` will be listened to, and the post will not
be paginated. That is clearly incorrect behavior.
While failing to explicitly and strictly check the return value of
strpos() is a code smell, it helps when bug reports point out ''why''
something smells, as well as any repercussions. In this case, I had felt
that the implicit > 0 (needle in haystack, and needle not at start of
haystack) was correct.
So — I think this would be best with pieces of both the current and old
behaviors: Ignore `<!--nextpage-->` at the start of the string (so, no
empty page), but don't let it prevent pagination.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16746#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list