Opened 6 months ago
Last modified 4 months ago
#64556 new defect (bug)
Tools -> Export | Failure when setting category
| Reported by: | kbpcit | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Export | Version: | 6.9 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
Hi,
Export of posts fails when exporting posts of a specific category. This probably has affect on other export settings as well.
File /wp-admin/includes/export.php, line 543 is supposed to echo the slug of the current category's parent. It is trying to get that data from the $cats variable, which normally contains all the categories, but it does not contain that data when limiting the posts to export to a specific category.
Current line 543:
<wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent>
Suggested fix:
<wp:category_parent><?php echo wxr_cdata( $c->parent && isset( $cats[ $c->parent ] ) ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent>
Blessings,
Klaas
Attachments (1)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
The issue is that when exporting posts filtered by a specific category, the $cats array is only populated with the categories relevant to the export — not all categories. If a category has a parent that isn't in $cats, accessing $cats[ $c->parent ] triggers an undefined index error.
The fix adds an isset() guard before accessing the parent in the $cats array. I've also applied the same fix to the wp:term_parent line which has the identical problem with the $terms array when exporting filtered custom taxonomy terms.
Attaching patch: 64556.diff