Make WordPress Core

#56393 closed defect (bug) (duplicate)

Invalid default value for WP_Scripts->set_translations $path argument

Reported by: iviweb's profile iviweb Owned by: iviweb's profile iviweb
Milestone: Priority: normal
Severity: normal Version:
Component: Script Loader Keywords:
Focuses: Cc:

Description

Currently WP_Scripts->set_translations have arguments with bellow signature:

 * @param string $handle Name of the script to register a translation domain to.
 * @param string $domain Optional. Text domain. Default 'default'.
 * @param string $path   Optional. The full file path to the directory containing translation files.

But for $path argument default value is set as NULL.

WP_Scripts extends from WP_Dependencies, which have items _WP_Dependency, in this class we also have set_translations method with arguments:

* @param string $domain The translation textdomain.
* @param string $path   Optional. The full file path to the directory containing translation files.

And there also $path default value is NULL.

These methods are calling load_script_textdomain function, which also have the same issue. Declared signature:

 * @param string $handle Name of the script to register a translation domain to.
 * @param string $domain Optional. Text domain. Default 'default'.
 * @param string $path   Optional. The full file path to the directory containing translation files.

and default for $path is NULL.

All these signature/default differences cause issue:

PHP Deprecated:  rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in C:\xampp\htdocs\tps\wp-includes\formatting.php on line 2772

because finally these methods are using

<?php
$path   = untrailingslashit( $path );

which is called rtrim() with passed $path, and we are getting warning about invalid input type.

So, we need for all these methods to set $path argument default value as empty string, instead of NULL

Change History (1)

#1 @ocean90
20 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from assigned to closed
  • Version trunk deleted

Hello @iviweb, thanks for the report. We're already tracking this issue in #55967.

Note: See TracTickets for help on using tickets.