WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#37028 closed defect (bug) (maybelater)

Taxonomy terms array to string conversion in class-wp-ajax-response.php

Reported by: esemlabel Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5.2
Component: Taxonomy Keywords:
Focuses: Cc:

Description

When adding or deleting single term on custom taxonomy page will always return PHP Notice: Array to string conversion in \wp-includes\class-wp-ajax-response.php on line 119

<?php
if ( is_array( $r['supplemental'] ) ) {
    foreach ( $r['supplemental'] as $k => $v ) {
        $s .= "<$k><![CDATA[$v]]></$k>";
    }
    $s = "<supplemental>$s</supplemental>";
}

The issue exist even on freshly installed WP with or without any plugins, But does not exist on bulk deleting.

Change History (4)

#1 @boonebgorges
3 years ago

  • Keywords reporter-feedback added

Hi @esemlabel - Can you please provide more details? I can't reproduce, and I'm unsure how this would happen on a default installation of WordPress.

Here's what I tried:

  1. Register a custom taxonomy 'foo'
  2. Create a term in the taxonomy at wp-admin/edit-tags.php?taxonomy=foo
  3. Hover over the newly created term in the list table and click delete
  4. Term is deleted as expected

Is this what you're doing?

The AJAX handler that WP uses when deleting a term in this way doesn't even create a WP_AJAX_Response object, so I'm unsure how deleting would cause the notice you've described. https://core.trac.wordpress.org/browser/tags/4.5.2/src/wp-admin/includes/ajax-actions.php#L579

'supplemental' data is added when you successfully create a term. The two types of 'supplemental' data https://core.trac.wordpress.org/browser/tags/4.5.2/src/wp-admin/includes/ajax-actions.php?marks=861,866#L819:

  1. An array array( 'noparents' => $noparents, 'parents' => $parents ), where $noparents and $parents are strings (markup for a row of the list table).
  2. A WP_Term object, cast to array.

It's not clear to me how either one of these would end up with a nested array.

If you can provide more debugging info - in particular, the value of 'supplemental' that's causing the problem - it would be helpful. You can get this info by looking at the response sent by the AJAX request, using your browser's Network inspector.

#2 @esemlabel
3 years ago

I am sorry, but I found what cause this issue.
One of my theme's included php file contained one space character after close php tag

?>  <- one space here

I didn't mentioned WP does not trim content, and it is miracle that I could find this lone space. In other cases, find a such mistake would be impossible. 'WP_DEBUG' and 'WP_DEBUG_LOG' couldn't catch this.

Update: the problem still exist. The promlem appears on any term (category, tags or custom taxonomy) when adding tag or term. I am trying to find what cause this. Will keep you update.

Last edited 3 years ago by esemlabel (previous) (diff)

#3 @esemlabel
3 years ago

  • Resolution set to maybelater
  • Status changed from new to closed

I have found what cause debug loggin.
Tрe problem was in qtranslate plugin.
https://github.com/qTranslate-Team/qtranslate-x/releases/tag/3.4.6.9

Will send report to plugin developer.

Thanks for concern!

Version 0, edited 3 years ago by esemlabel (next)

#4 @swissspidy
3 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.