Export: Fix fatal error when passing null to wxr_cdata() by casting passed value to string.

This ensures that `wp_is_valid_utf8()` does not cause a type error since it only accepts strings. 

Developed in https://github.com/WordPress/wordpress-develop/pull/10595

Follow-up to [60630].

Props hbhalodia, westonruter, desrosj, albigdd, jorbin.
See #38044.
Fixes #64347.

Built from https://develop.svn.wordpress.org/trunk@61405


git-svn-id: http://core.svn.wordpress.org/trunk@60717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter
2025-12-24 06:48:31 +00:00
parent 3429087f6c
commit 4ab8f3d7f2
2 changed files with 4 additions and 2 deletions

View File

@@ -239,10 +239,12 @@ function export_wp( $args = array() ) {
*
* @since 2.1.0
*
* @param string $str String to wrap in XML CDATA tag.
* @param string|null $str String to wrap in XML CDATA tag. May be null.
* @return string
*/
function wxr_cdata( $str ) {
$str = (string) $str;
if ( ! wp_is_valid_utf8( $str ) ) {
$str = utf8_encode( $str );
}

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.0-alpha-61404';
$wp_version = '7.0-alpha-61405';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.