#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)
This ticket was mentioned in PR #266 on WordPress/wordpress-develop by Zebedeu.
5 years ago
#3
The wxr_cdata() function was replaced by intval() in wxr_cdata( $t->term_id ).
#5
@
5 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 47789:
5 years ago
#6
Committed in https://core.trac.wordpress.org/changeset/47789.
Note: See
TracTickets for help on using
tickets.
Good catch, thanks for the report.
Introduced in [34333] / #33732, appears to be a copy/paste error.