[wp-trac] [WordPress Trac] #59195: deprecation notice triggered in post.php by passing null to parameter #2 in preg_match()
WordPress Trac
noreply at wordpress.org
Tue Jun 18 14:44:38 UTC 2024
#59195: deprecation notice triggered in post.php by passing null to parameter #2 in
preg_match()
-------------------------------------------------+-------------------------
Reporter: nosilver4u | Owner:
| hellofromTonya
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.6
Component: Media | Version: 6.3
Severity: normal | Resolution: fixed
Keywords: php81 has-patch has-unit-tests has- | Focuses: php-
testing-info commit | compatibility
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):
* status: reviewing => closed
* resolution: => fixed
Comment:
In [changeset:"58437" 58437]:
{{{
#!CommitTicketReference repository="" revision="58437"
Code Modernization: Fix non-nullable deprecation in
get_available_post_mime_types().
Fixes a PHP 8.1 and above "null to non-nullable" deprecation notice in
`get_available_post_mime_types()`:
{{{
Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type
string is deprecated in ./wp-includes/post.php on line 3395
}}}
[https://developer.wordpress.org/reference/functions/get_available_post_mime_types/#return
This function is documented] to:
* Return `An array of MIME types.`
* as an array of `string`s, i.e. `string[]`.
A `null` or empty element within the returned array is not a valid MIME
type. If a `null` exists in the returned array, it is the root cause of
PHP throwing the deprecation notice.
This commit removes the `null` and empty elements from the returned array
of MIME types. It also adds a unit test.
Follow-up to [56623], [56452].
Props nosilver4u, jrf, ironprogrammer, antpb, antonvlasenko, rajinsharwar,
hellofromTonya.
Fixes #59195.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59195#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list