WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#43804 new defect (bug)

Undefined offset: 0 in ../wp-includes/taxonomy.php on line 1903

Reported by: vasyltech Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Taxonomy Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

The issue is pretty trivial. When there are no terms assigned to a post, the condition on 1894 will return false and this immediately will cause PHP error because $taxonomies array does not have any records inside.

To reproduce the issue, simply call wp_get_object_terms function with post, page or custom post type that does not have a single hierarchical term assigned to.

Attachments (2)

fix.patch (89 bytes) - added by vasyltech 2 months ago.
Straight forward fix for the "PHP Notice: Undefined offset: 0 in ../wp-includes/taxonomy.php on line 1903" error
43804.diff (793 bytes) - added by birgire 2 months ago.

Download all attachments as: .zip

Change History (3)

@vasyltech
2 months ago

Straight forward fix for the "PHP Notice: Undefined offset: 0 in ../wp-includes/taxonomy.php on line 1903" error

@birgire
2 months ago

#1 @birgire
2 months ago

  • Component changed from General to Taxonomy
  • Keywords reporter-feedback added

Welcome to WordPress Trac @vasyltech

Thanks for the report.

But I'm unable to reproduce this.

I've attached my test in 43804.diff

Can you elaborate further how we can reproduce the bug?

Thanks.

Note: See TracTickets for help on using tickets.