Opened 4 weeks ago
Last modified 6 days ago
#64347 reopened defect (bug)
Fatal error when `wxr_cdata()` is called with non-string value
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9.1 | Priority: | normal |
| Severity: | normal | Version: | 6.9 |
| Component: | Export | Keywords: | has-patch has-unit-tests dev-feedback fixed-major |
| Focuses: | Cc: |
Description
From βthis issue on the wp.org Support forums:
Hi
During export, a page opens with this message: βThis site is unreachable. Website at βhttps://kamerydrogowe.wlkp.net.pl/wp-admin/export.php?.. may be temporarily unavailable or may have been permanently moved to a new internet address. ERR_INVALID_RESPONSEβ
WordPress, themes, plugins β updated. Theme enabled on Twenty tweny β still a problem. Plugin cache cleared, web browser cache and cookies cleared β still the problem. All plugins disabled β export downloads, but only 1.1 Mb instead of about 16 Mb.
I also got the message: βThe old WordPress core file was not removed during the update: wp-includes/SimplePie/src/Core.phpβ
The following log output was followed in a follow up response:
[03-Dec-2025 20:47:17 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /wp-config.php:103) in /wp-includes/functions.php on line 7182
[03-Dec-2025 20:47:17 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /wp-config.php:103) in /wp-admin/includes/export.php on line 96
[03-Dec-2025 20:47:17 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /wp-config.php:103) in /wp-admin/includes/export.php on line 97
[03-Dec-2025 20:47:17 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /wp-config.php:103) in /wp-admin/includes/export.php on line 98
[03-Dec-2025 20:47:17 UTC] PHP Fatal error: Uncaught TypeError: wp_is_valid_utf8(): Argument #1 ($bytes) must be of type string, null given, called in /wp-admin/includes/export.php on line 246 and defined in /wp-includes/utf8.php:39
Stack trace:
#0
/wp-admin/includes/export.php(246): wp_is_valid_utf8(NULL)
#1
/wp-admin/includes/export.php(682): wxr_cdata(NULL)
#2
/wp-admin/export.php(123): export_wp(Array)
#3 {main}
thrown in
/wp-includes/utf8.php on line 39
Change History (18)
This ticket was mentioned in βPR #10595 on βWordPress/wordpress-develop by β@hbhalodia.
4 weeks ago
#3
- Keywords has-patch added
- Add soft type safe check to
wxr_cdatafunction, and typecast the incoming input to string.
Trac ticket: https://core.trac.wordpress.org/ticket/64347
#4
@
4 weeks ago
Hi @swissspidy @desrosj
Since wp_is_valid_utf8 function is always expecting the incoming data to be string, we need o make sure what we send is always a string. Hence I have created a PR βhttps://github.com/WordPress/wordpress-develop/pull/10595, which adds the soft type-safe, Since we do not know what can be input to wxr_cdata function, hence strict type check won't be feasible at the moment (let me know if needs to be stricter check), but then we need to make sure where this function is called, the param should passed as string, else it can throw the fatal on this function.
#5
follow-up:
βΒ 6
@
4 weeks ago
Thanks for the pull request, @hbhalodia!
Before we decide which specific solution is best, I think there are a few things we should do.
First, we should look into how were NULL or other non-string values exported in WordPress 6.8? Are they preserved? Converted to a string? Something else?
We should also write some unit tests that tests NULL
@hbhalodia are you able to help with either of these?
#6
in reply to:
βΒ 5
@
4 weeks ago
Replying to desrosj:
Thanks for the pull request, @hbhalodia!
Before we decide which specific solution is best, I think there are a few things we should do.
First, we should look into how were
NULLor other non-string values exported in WordPress 6.8? Are they preserved? Converted to a string? Something else?
We should also write some unit tests that tests
NULL
@hbhalodia are you able to help with either of these?
Sure, I will work on this and would provide an update soon.
Looking through
wp-admin/includes/export.php, it seems that there are a few possible culprits.If a plugin or theme is using a filter (
the_title_export/the_content_export/the_excerpt_export) to return a value a non-string value such asNULLor an integer, there is no protection in place for this and a fatal error will occur due to thestringtype safety defined forwp_is_valid_utf8(). Though that seems to be a scenario that could come up, I don't think that's the root cause in this case because the user is still seeing the issue after disabling all plugins.The other possibility is that a plugin or some custom code has explicitly set a meta value to a non-string value. Because
export_wp()performs direct database queries to retrieve post/term/comment metadata, there's no guarantee that non-string values will be converted to strings as expected.