[wp-trac] [WordPress Trac] #59716: Deprecated messages exporting post meta with meta_value null from PHP 8.1 and PHP 8.2
WordPress Trac
noreply at wordpress.org
Tue Oct 24 13:55:00 UTC 2023
#59716: Deprecated messages exporting post meta with meta_value null from PHP 8.1
and PHP 8.2
-------------------------------+-----------------------------
Reporter: bobbingwide | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Export | Version: trunk
Severity: normal | Keywords:
Focuses: php-compatibility |
-------------------------------+-----------------------------
Today I attempted to export some products from one database to import into
another.
I encountered several Deprecated messages emanating from code within
`wxr_cdata()`
It appears that the export code doesn't specifically cater for meta data
with null values.
Prior to PHP 8.1 the null values were treated as empty strings.
There are several plugins that are ''guilty'' of producing post meta data
containing nulls. Two of them are in the top 12 plugins by total
downloads: All-In-One-SEO-Pack and WooCommerce.
=== Actual output
Here's the exported post meta for WooCommerce's `_stock` field.
{{{
<wp:postmeta>
<wp:meta_key><![CDATA[_stock]]></wp:meta_key>
<wp:meta_value><br />
<b>Deprecated</b>: strlen(): Passing null to parameter #1 ($string) of
type string is deprecated in <b>C:\apache\htdocs\gardenvista\wp-
includes\formatting.php</b> on line <b>885</b><br />
<br />
<b>Deprecated</b>: str_replace(): Passing null to parameter #3 ($subject)
of type array|string is deprecated in <b>C:\apache\htdocs\gardenvista\wp-
admin\includes\export.php</b> on line <b>207</b><br />
<![CDATA[]]></wp:meta_value>
</wp:postmeta>
}}}
Both of these Deprecated messages can be avoided by a simple change as the
first line of `wxr_cdata()`
{{{
if ( null === $str ) {
$str = '';
}
}}}
=== Expected output:
- The export should complete without producing the Deprecated message
output in the post meta value.
- Null values should continue to be treated as empty strings
=== Environment:
- PHP 8.1.23 or PHP 8.2.10
- WordPress 6.4-RC1
- Plugins: WooCommerce and/or All-In-One-SEO
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59716>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list