#51320 closed defect (bug) (fixed)
PHP Notice while moving post to trash (post_type has 2 registered taxonomies both with default_term set)
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.5.2 | Priority: | normal |
Severity: | normal | Version: | 5.5.1 |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests commit fixed-major |
Focuses: | Cc: |
Description
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 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 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 isset( $postarr['tax_input'] )
is FLASE, but for second iteration it is TRUE that's why
<?php is_array( $postarr['tax_input'][ $taxonomy ] )
is throwing a notice because $taxonomy key isn't set in $postarr array.
Attachments (1)
Change History (10)
#1
@
4 years ago
- Milestone changed from Awaiting Review to 5.5.2
- Owner set to SergeyBiryukov
- Status changed from new to accepted
This ticket was mentioned in PR #596 on WordPress/wordpress-develop by yakimun.
4 years ago
#2
- Keywords has-patch has-unit-tests added
Corrected the check of the existence of an array key.
Trac ticket: https://core.trac.wordpress.org/ticket/51320
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
4 years ago
#5
@
4 years ago
- Keywords commit added; needs-testing removed
Hi,
Tested on my side: adding an isset
check to test the sub-array fixes the issue. It looks good to go.
Marking this for commit
and removing the related keyword.
#7
@
4 years ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for backporting to the 5.5 branch.
hellofromtonya commented on PR #596:
4 years ago
#9
Trac ticket was closed with changeset https://core.trac.wordpress.org/changeset/49332.
Hi there, thanks for the ticket!
Introduced in [48480].