Make WordPress Core

Opened 10 years ago

Last modified 5 years ago

#27326 new defect (bug)

wp_list_pages - exclude parameter changes behaviour depending on depth

Reported by: nosnurg's profile nosnurg Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Posts, Post Types Keywords: has-patch needs-testing
Focuses: Cc:

Description

Let's say I have four top level pages with IDs 1,2 and 3 and each has three children, say, (11,12,13), (21,22,23) and (31,32,33).

If I run

<?php wp_list_pages(); ?>

on that I'll get all the pages shown. So it'll be a list like:

1
    11
    12
    13
2
    21
    22
    23
3
    31
    32
    33

If I run

<?php wp_list_pages(exclude=3); ?>

then page 3 will not be shown and the hierarchy will collapse so 31,32,33 appear in the top level of the hierarchy. So what I'll get is:


1
    11
    12
    13
2
    21
    22
    23
31
32
33

Given the existence of a separate exclude_tree argument, that is pretty much what I'd expect to happen, after all it has to show the child pages somehow. If I now introduce a depth argument so it is:

<?php wp_list_pages(depth=3&exclude=3); ?>

I'd expect the same thing to happen as the depth shouldn't make any difference. What actually happens is that the

exclude now behaves similarly to exclude_tree. What I actually get is:

1
  11 12 13
2
  21 22 23

Now that to me doesn't make sense.

Attachments (4)

27326-unit-tests.diff (17.8 KB) - added by MikeHansenMe 10 years ago.
Unit tests for wp_list_pages
27326-unit-tests.2.diff (17.4 KB) - added by MikeHansenMe 10 years ago.
minor updates to tests and cleanup
27326.diff (753 bytes) - added by MikeHansenMe 10 years ago.
27326-unittests.diff (1.8 KB) - added by MikeHansenMe 9 years ago.
see #30284

Download all attachments as: .zip

Change History (11)

#1 @nosnurg
10 years ago

Apologies for somewhat untidy formatting, and please note I did mean to write:

1
    11
    12
    13
2
    21
    22
    23

for the last bit.

#2 @nosnurg
10 years ago

The bug, if that is what it is, would seem to remain in 3.9.0.

@MikeHansenMe
10 years ago

Unit tests for wp_list_pages

#3 @MikeHansenMe
10 years ago

I was able to confirm this. I wrote some unit tests for wp_list_pages that test the arguments. The final test in the set is for this ticket.

@MikeHansenMe
10 years ago

minor updates to tests and cleanup

@MikeHansenMe
10 years ago

#4 @MikeHansenMe
10 years ago

  • Keywords has-patch needs-testing added

#5 @wonderboymusic
10 years ago

In 28400:

Add unit tests for wp_list_pages().

Props MikeHansenMe.
See #27326.

#6 @DrewAPicture
10 years ago

  • Component changed from General to Posts, Post Types

#7 @MikeHansenMe
9 years ago

27326.diff still applies and has unit tests in 27326-unittests.diff. These tests were added then removed during #30284 because they were failing. The test was for this bug and passes with the patch.

Note: See TracTickets for help on using tickets.