[wp-trac] [WordPress Trac] #51320: PHP Notice while moving post to trash (post_type has 2 registered taxonomies both with default_term set)
WordPress Trac
noreply at wordpress.org
Wed Sep 16 06:29:04 UTC 2020
#51320: PHP Notice while moving post to trash (post_type has 2 registered
taxonomies both with default_term set)
-------------------------------+-----------------------------
Reporter: szaqal21 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 5.5.1
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
While moving post to trash a PHP Notice is thrown:
{{{
PHP Notice: Undefined index: logaction in /var/www/html/czt.dev.puw.rz
/wp-includes/post.php on line 4053
}}}
post_type has 2 registered taxonomies both with default_term set.
Taxonomy "logaction" is registered as second, first is "logontype" and for
this taxonomy no notice is thrown.
I think that this condition:
{{{#!php
<?php
if ( isset( $postarr['tax_input'] ) && is_array( $postarr['tax_input'][
$taxonomy ] ) ) {
$postarr['tax_input'][ $taxonomy ] = array_filter(
$postarr['tax_input'][ $taxonomy ] );
}
}}}
should be changed to:
{{{#!php
<?php
if ( isset( $postarr['tax_input'][ $taxonomy ] ) && is_array(
$postarr['tax_input'][ $taxonomy ] ) ) {
$postarr['tax_input'][ $taxonomy ] = array_filter(
$postarr['tax_input'][ $taxonomy ] );
}
}}}
This notice wasn't thrown when I had only 1 taxonomy registered, it showed
after registering second taxonomy.
On first loop iteration
{{{#!php
<?php
isset( $postarr['tax_input'] )
}}}
is FLASE, but for second iteration it is TRUE that's why
{{{#!php
<?php
is_array( $postarr['tax_input'][ $taxonomy ] )
}}}
is throwing a notice because $taxonomy key isn't set in $postarr array.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51320>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list