mirror of
git://develop.git.wordpress.org/
synced 2025-02-07 16:10:43 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@54349 602fd350-edb4-49c9-b593-d223f7449a82
The short version: 1. Create a clean MySQL database and user. DO NOT USE AN EXISTING DATABASE or you will lose data, guaranteed. 2. Copy wp-tests-config-sample.php to wp-tests-config.php, edit it and include your database name/user/password. 3. $ svn up 4. Run the tests from the "trunk" directory: To execute a particular test: $ phpunit tests/phpunit/tests/test_case.php To execute all tests: $ phpunit Notes: Test cases live in the 'tests' subdirectory. All files in that directory will be included by default. Extend the WP_UnitTestCase class to ensure your test is run. phpunit will initialize and install a (more or less) complete running copy of WordPress each time it is run. This makes it possible to run functional interface and module tests against a fully working database and codebase, as opposed to pure unit tests with mock objects and stubs. Pure unit tests may be used also, of course. Changes to the test database will be rolled back as tests are finished, to ensure a clean start next time the tests are run. phpunit is intended to run at the command line, not via a web server.