[wp-trac] [WordPress Trac] #60052: Error when deleting media if default taxonomies have been removed
WordPress Trac
noreply at wordpress.org
Tue Dec 12 07:44:20 UTC 2023
#60052: Error when deleting media if default taxonomies have been removed
--------------------------+-----------------------------
Reporter: imatoni | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.4.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Hello,
I recently had a problem with deleting media from the media library.
I received the following error message:
2151#0: *203114 FastCGI sent in stderr: "PHP message: UM_TEST_ERROR_LOG
PHP message: 63870
PHP message: "category"
PHP message: UM_TEST_ERROR_LOG
PHP message: 63870
PHP message: "post_tag"
PHP message: PHP Fatal error: Uncaught TypeError: array_map(): Argument #2
($array) must be of type array, WP_Error given in /var/www/vhosts/fis-
gmbh.de/stage.fis-gmbh.de/wp-includes/taxonomy.php:1964
Stack trace:
#0 /var/www/vhosts/fis-gmbh.de/stage.fis-gmbh.de/wp-
includes/taxonomy.php(1964): array_map()
#1 /var/www/vhosts/fis-gmbh.de/stage.fis-gmbh.de/wp-
includes/post.php(6304): wp_delete_object_term_relationships()
#2 /var/www/vhosts/fis-gmbh.de/stage.fis-gmbh.de/wp-
includes/post.php(3416): wp_delete_attachment()
#3 /var/www/vhosts/fis-gmbh.de/stage.fis-gmbh.de/wp-admin/includes/ajax-
actions.php(886): wp_delete_post()
#4 /var/www/vhosts/fis-gmbh.de/stage.fis-gmbh.de/wp-includes/class-wp-
hook.php(324): wp_ajax_delete_post()
#5 /var/www/vhosts/fis-gmbh.de/stage.fis-gmbh.de/wp-includes/class-wp-
hook.php(348): WP_Hook->apply_filters()
#6 /var/www/vhosts/fis-gmbh.de/stage.fis-gmbh.de/wp-
includes/plugin.php(517): WP_Hook->do_action()
#7 /var/www/vhosts/fis-gmbh.de/stage.fis-gmbh.de/wp-admin/admin-
ajax.php(1" while reading response header from upstream
This happened because we had used the following code elsewhere:
add_action( 'init', 'deregister_tag' );
function deregister_tag() {
global $wp_taxonomies;
$tax = 'post_tag';
if ( taxonomy_exists( $tax ) ) {
unset( $wp_taxonomies[ $tax ] );
}
}
This code ensures that the standard WordPress taxonomy 'post_tag' is no
longer present (this was not necessary for this project).
In wp-includes/post.php there is the following call:
wp_delete_object_term_relationships( $post_id, array( 'category',
'post_tag' ) );
This call causes an error to occur if the taxonomy 'post_tag' is not
present.
I am of the opinion that this error should be caught in the WordPress
core.
This issue is also being discussed here at WPML:
https://wpml.org/forums/topic/fatal-error-when-deleting-a-media/
Thank you.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60052>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list