[wp-trac] [WordPress Trac] #55656: PHP 8.x: various compatibility fixes for WordPress 6.1

WordPress Trac noreply at wordpress.org
Wed Sep 28 17:32:08 UTC 2022


#55656: PHP 8.x: various compatibility fixes for WordPress 6.1
-------------------------------------------------+-------------------------
 Reporter:  hellofromTonya                       |       Owner:
                                                 |  SergeyBiryukov
     Type:  task (blessed)                       |      Status:  accepted
 Priority:  normal                               |   Milestone:  6.1
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  php8 php81 has-patch has-unit-tests  |     Focuses:  coding-
                                                 |  standards
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 In [changeset:"54349" 54349]:
 {{{
 #!CommitTicketReference repository="" revision="54349"
 Code Modernization: Use correct default value for JavaScript translations
 path.

 The `$path` parameter of `load_script_textdomain()` had a default value of
 `null`, but would be passed onto the `untrailingslashit()` function
 without any input validation, even though the latter explicitly only
 expects/supports a string input.

 This commit changes the default value for `$path` to an empty string, and
 adds an `is_string()` check before passing the value to
 `untrailingslashit()` to fix the issue at the point where the invalid
 input is incorrectly (not) validated.

 Note: Changing the `untrailingslashit()` function is outside the scope of
 this commit.

 Includes:
 * Adding a dedicated unit test for this issue.
 * Correcting the default value for `$path` from `null` to an empty string
 in a few related methods and functions:
  * `WP_Dependency::set_translations()`
  * `WP_Scripts::set_translations()`
  * `wp_set_script_translations()`
  * `load_script_textdomain()`

 This fix also allows to remove a couple of calls to `expectDeprecation()`
 in unrelated tests.

 Fixes an error when running the test suite:
 {{{
 4) Tests_Dependencies_Scripts::test_wp_external_wp_i18n_print_order
 rtrim(): Passing null to parameter #1 ($string) of type string is
 deprecated

 /var/www/src/wp-includes/formatting.php:2782
 /var/www/src/wp-includes/l10n.php:1068
 /var/www/src/wp-includes/class.wp-scripts.php:605
 /var/www/src/wp-includes/class.wp-scripts.php:320
 /var/www/src/wp-includes/class.wp-dependencies.php:136
 /var/www/src/wp-includes/functions.wp-scripts.php:109
 /var/www/tests/phpunit/tests/dependencies/scripts.php:1505
 /var/www/tests/phpunit/includes/utils.php:436
 /var/www/tests/phpunit/tests/dependencies/scripts.php:1507
 /var/www/vendor/bin/phpunit:123
 }}}

 Follow-up to [44169], [44607], [51968].

 Props jrf, ocean90, Chouby, swissspidy, lovor, iviweb, meysamnorouzi,
 DarkoG, oneearth27, SergeyBiryukov.
 Fixes #55967. See #55656.
 }}}

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


More information about the wp-trac mailing list