Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#23272 closed defect (bug) (fixed)

Notice on class-wp-walker.php

Reported by: rodrigosprimo Owned by: SergeyBiryukov
Priority: normal Milestone: 3.6
Component: Warnings/Notices Version: 2.7
Severity: normal Keywords: has-patch commit dev-reviewed
Cc: Focuses:

Description

When using the Walker class I get the following notice:

Notice: Undefined offset: 0 in wp-includes/class-wp-walker.php on line 126

//display this element
if ( is_array( $args[0] ) )
    $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );

If I'm not mistaken, this problem is happening because the code assumes that the $args variable is always a non empty array which is not the case.

I'm attaching the code I used to reproduce the problem and a patch to fix it.

Attachments (2)

class-wp-walker.php.patch (595 bytes ) - added by rodrigosprimo 14 years ago.
Patch
walker_example.php (641 bytes ) - added by rodrigosprimo 14 years ago.
Code used to reproduce the bug

Download all attachments as: .zip

Change History (6)

@rodrigosprimo
14 years ago

Code used to reproduce the bug

#1 @rmccue
14 years ago

  • Keywords has-patch commit added

Looks good to me.

#2 @SergeyBiryukov
14 years ago

  • Milestone Awaiting Review3.6
  • Version trunk2.7

Introduced in [9830].

#3 @nacin
14 years ago

  • Keywords dev-reviewed added

Looks good, yes.

#4 @SergeyBiryukov
14 years ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

In 23346:

Make sure the array exists before adding an element to it. props rodrigosprimo. fixes #23272.

Note: See TracTickets for help on using tickets.