[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
Wed Apr 24 23:18:03 UTC 2024


#59195: deprecation notice triggered in post.php by passing null to parameter #2 in
preg_match()
-------------------------------------------------+-------------------------
 Reporter:  nosilver4u                           |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  6.6
Component:  Media                                |     Version:  6.3
 Severity:  normal                               |  Resolution:
 Keywords:  php81 has-patch has-unit-tests       |     Focuses:  php-
  needs-testing has-testing-info                 |  compatibility
-------------------------------------------------+-------------------------
Changes (by ironprogrammer):

 * keywords:  php81 has-patch has-unit-tests needs-testing => php81 has-
     patch has-unit-tests needs-testing has-testing-info
 * milestone:  Awaiting Review => 6.6


Comment:

 == Testing Instructions

 I added the following to an mu plugin to force a null into the available
 post mime types:

 {{{#!php
 add_filter( 'pre_get_available_post_mime_types',
 'override_post_mime_types' );
 function override_post_mime_types( $type ) {
     return array( 'image/jpeg', null, 'image/png' );
 }
 }}}

 You can alternatively clear the `post_mime_type` from an attachment in the
 DB, more closely matching comment:9.

 === Steps to Reproduce
 1. Set up your environment to use PHP 8.1+.
 2. Implement the above mu plugin, OR find an attachment in `wp_posts` and
 clear its `post_mime_type` value (keep track of what you changed here in
 case you need to set it back).

 === Expected Results
 When reproducing the bug:
 - ❌ Load the Media page in your environment, observe the logged
 deprecation notices identified in the [#ticket report].
 - ❌ [Optional] From the console, run `wp eval "print_r(
 get_available_post_mime_types( 'attachment' ) );"` or use `wp shell` to
 call `get_available_post_mime_types( 'attachment' );` directly. Observe
 that the returned array contains a null (blank).

 When testing a patch to validate it works as expected:
 - ✅ Load the Media page. The deprecation notices should no longer be
 present.
 - ✅ [Optional] From the `wp` console commands, the returned array should
 not contain nulls (blanks).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59195#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list