[wp-trac] [WordPress Trac] #50113: No need to do wxr_cdata( $t->term_id ) foreach $terms?
WordPress Trac
noreply at wordpress.org
Thu May 7 12:31:38 UTC 2020
#50113: No need to do wxr_cdata( $t->term_id ) foreach $terms?
--------------------------+-----------------------------
Reporter: DrLightman | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Export | Version: 5.4.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
In **\wp-admin\includes\export.php** line 504.
{{{#!php
<?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 )**.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50113>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list