Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#4870 closed defect (bug) (wontfix)

Bug in get_categories when asking for category children

Reported by: hovenko Owned by: ryan
Priority: high Milestone:
Component: General Version: 2.2.2
Severity: major Keywords: categories
Cc:

Description (last modified by foolswisdom)

When asking for categories that are child of another category (cat1) and to
include empty categories I get different behaviour wether cat1 has children
or not.

Take the following code:

$cat_children   = get_categories(
        array(
                'child_of'      => 1,
                'hide_empty'    => false,
        );
);

print_r($cat_children);

Scenario 1:
I have the following categories:

1 - cat1 (no parent)
2 - cat2 (no parent)
3 - cat3 (parent:1)

In this case it prints out cat3.

Scenario 2:
I have the following categories:

1 - cat1 (no parent)
2 - cat2 (no parent)

In this case it prints out cat1 and cat2.

Expected behaviour is to get an empty list, simply because cat1
doesn't have any children.

Attachments (1)

category.php.patch (378 bytes) - added by hovenko 6 years ago.
Patch for the file wp-includes/category.php

Download all attachments as: .zip

Change History (8)

  • Description modified (diff)
  • Milestone changed from 2.2.3 to 2.3

comment:2   ryan6 years ago

  • Owner changed from anonymous to ryan

I don't understand why the milestone was changed to 2.3. This is the time for fixing bugs, right? From my point of view, this is a bug.

I believe the fix is as simple as checking if both the category hierarchy is empty and "child_of" is set, then return an empty array.

hovenko6 years ago

Patch for the file wp-includes/category.php

comment:4   DD326 years ago

I don't understand why the milestone was changed to 2.3. This is the time for fixing bugs, right? From my point of view, this is a bug.

2.3 is due on September 24th, There may be a 2.2.3 release before then, but i'm not sure.
Since its dealing with Categories, and we've got a new category backend in 2.3, it'd make sense to simply focus the testing on the new stuff instead.

I cant reproduce the issue in 2.3 either, So it looks to me its fixed there.

2.3 Release Info: http://comox.textdrive.com/pipermail/wp-hackers/2007-August/013962.html

  • Milestone changed from 2.3 to 2.2.3

DD32, thanks for testing this in 2.3! Since you say it doesn't repro, changing milestone back to 2.2.3 .

comment:6   DD325 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Not an issue in 2.3, or 2.4(trunk), closing ticket.

  • Milestone 2.2.3 deleted
Note: See TracTickets for help on using tickets.