WordPress.org

Make WordPress Core

Opened 14 months ago

Closed 13 months ago

Last modified 13 months ago

#50113 closed defect (bug) (fixed)

No need to do wxr_cdata( $t->term_id ) foreach $terms?

Reported by: DrLightman Owned by: SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.4.1
Component: Export Keywords: good-first-bug has-patch
Focuses: Cc:

Description

In \wp-admin\includes\export.php line 504.

<?php foreach ( $terms as $t ) : ?>
<wp:term>
!       <wp:term_id><?php echo wxr_cdata( $t->term_id ); ?></wp:term_id>
        <wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy>

This code causes a series of Notices in the resulting xml for each dumped $term when display errors is on:

<wp:term>
	<wp:term_id><br />
<b>Notice</b>:  Trying to access array offset on value of type int in <b>D:\Siti\NOPE\wp-includes\formatting.php</b> on line <b>902</b><br />
<br />
<b>Notice</b>:  Trying to access array offset on value of type int in <b>D:\Siti\NOPE\wp-includes\formatting.php</b> on line <b>902</b><br />
<br />
<b>Notice</b>:  Trying to access array offset on value of type int in <b>D:\Siti\NOPE\wp-includes\formatting.php</b> on line <b>902</b><br />
<br />
<b>Notice</b>:  Trying to access array offset on value of type int in <b>D:\Siti\NOPE\wp-includes\formatting.php</b> on line <b>902</b><br />
<br />
<b>Notice</b>:  Trying to access array offset on value of type int in <b>D:\Siti\NOPE\wp-includes\formatting.php</b> on line <b>902</b><br />
<br />
<b>Notice</b>:  Trying to access array offset on value of type int in <b>D:\Siti\NOPE\wp-includes\formatting.php</b> on line <b>902</b><br />
<![CDATA[305391]]></wp:term_id>
	<wp:term_taxonomy><![CDATA[post_flag]]></wp:term_taxonomy>
	<wp:term_slug><![CDATA[custom-flag1]]></wp:term_slug>
	<wp:term_parent><![CDATA[]]></wp:term_parent>
	<wp:term_name><![CDATA[Custom Flag 1]]></wp:term_name>
</wp:term>

Because wxr_cdata() executes a seems_utf8() on an int I suppose.

Other dumps such as for the $tags do a simple intval() on the ->id instead not causing Notices.

Solution: replace wxr_cdata() with intval() in wxr_cdata( $t->term_id ).

Change History (6)

#1 @SergeyBiryukov
14 months ago

  • Milestone changed from Awaiting Review to 5.5

Good catch, thanks for the report.

Introduced in [34333] / #33732, appears to be a copy/paste error.

#2 @SergeyBiryukov
14 months ago

  • Keywords needs-patch good-first-bug added

This ticket was mentioned in PR #266 on WordPress/wordpress-develop by Zebedeu.


13 months ago

The wxr_cdata() function was replaced by intval() in wxr_cdata( $t->term_id ).

https://core.trac.wordpress.org/ticket/50113

#4 @Marcio Zebedeu
13 months ago

  • Keywords has-patch added; needs-patch removed

#5 @SergeyBiryukov
13 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 47789:

Export: Use correct escaping function for term IDs in <wp:term> nodes.

Follow-up to [34333].

Props DrLightman, marcio-zebedeu.
Fixes #50113.

Note: See TracTickets for help on using tickets.