46147 Commits

Author SHA1 Message Date
Sergey Biryukov
286fe4ceb0 Upgrade/Install: Make WP_Filesystem_FTPext::size() return false on failure.
While `WP_Filesystem_Base::size()` is documented to return `false` on failure, `ftp_size()` returns -1, and the method documentation was recently updated to reflect that.

This commit restores the previous `@return` tag and corrects the actual return value instead, to bring consistency with all the other `WP_Filesystem_*::size()` methods:
* `WP_Filesystem_Base::size()`
* `WP_Filesystem_Direct::size()`
* `WP_Filesystem_ftpsockets::size()`
* `WP_Filesystem_SSH2::size()`
{{{
@return int|false Size of the file in bytes on success, false on failure.
}}}

This better matches the purpose of the API to provide a consistent interface for various filesystem implementations.

Follow-up to [6779], [30678], [45226], [53860], [53862].

Fixes #51170.

git-svn-id: https://develop.svn.wordpress.org/trunk@53898 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-16 13:39:58 +00:00
Sergey Biryukov
37368555a5 Database: Ignore display width for integer data types in dbDelta() on MySQL 8.0.17 or later.
MySQL 8.0.17 deprecated the display width attribute for integer data types:
> As of MySQL 8.0.17, the `ZEROFILL` attribute is deprecated for numeric data types, as is the display width attribute for integer data types. You should expect support for `ZEROFILL` and display widths for integer data types to be removed in a future version of MySQL. Consider using an alternative means of producing the effect of these attributes. For example, applications can use the `LPAD()` function to zero-pad numbers up to the desired width, or they can store the formatted numbers in `CHAR` columns.

In practice, this means that display width is removed for integer types when creating a table:
* `BIGINT(20)` → `BIGINT`
* `INT(11)` → `INT`
* `MEDIUMINT(9)` → `MEDIUMINT`
* `SMALLINT(6)` → `SMALLINT`
* `TINYINT(4)` → `TINYINT`

Note: This only applies specifically to MySQL 8.0.17 or later. In MariaDB, display width for integer types is still available and expected.

This commit ensures that `dbDelta()`, which relies on the `DESCRIBE` SQL command to get the existing table structure and field types, when running on MySQL 8.0.17 or later, does not unnecessarily attempt to convert `BIGINT` fields back to `BIGINT(20)`, `INT` back to `INT(11)`, etc. When comparing the field type in the query with the existing field type, if display width is the only difference, it can be safely ignored to match MySQL behavior.

The change is covered by existing `dbDelta()` unit tests:
* A test for not altering `wp_get_db_schema()` queries on an existing install using MySQL 8.0.17+ now passes.
* More than twenty tests which previously failed on PHP 8.0.x + MariaDB due to incorrect expectations, caused by MariaDB version reporting not being consistent between PHP versions, now pass.

References:
* [https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html MySQL: Nymeric Type Attributes]
* [https://mariadb.com/kb/en/data-types-numeric-data-types/ MariaDB: Numeric Data Types]

Follow-up to [1575], [18899], [37525], [47183], [47184].

Props SergeyBiryukov, pbearne, leewillis77, JavierCasares, desrosj, costdev, johnbillion.
Fixes #49364. See #51740.

git-svn-id: https://develop.svn.wordpress.org/trunk@53897 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-15 13:16:22 +00:00
Sergey Biryukov
d51b039755 Coding Standards: Restore correct regex formatting in dbDelta().
An earlier regex for normalizing index definitions disables the PHPCS check for extra padding in order to keep a more readable indentation. However, this was missed for index columns regex.

Follow-up to [37583], [42228], [42249], [42343].

See #55647.

git-svn-id: https://develop.svn.wordpress.org/trunk@53896 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-14 02:12:22 +00:00
John Blackbourn
0e04c0a621 Build/Test Tools: Move the Memcached container into the Docker Compose config.
This allows a developer to use the persistent Memcached object cache on their local development environment via the `LOCAL_PHP_MEMCACHED` environment variable.

Enable the memcached config via `LOCAL_PHP_MEMCACHED=true` in the `.env` file and then restart the environment with `npm run env:restart`.

Fixes #55700


git-svn-id: https://develop.svn.wordpress.org/trunk@53895 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 23:23:26 +00:00
John Blackbourn
33368fc8c5 Taxonomy: Add a test file that was missed in [53893].
See #56215


git-svn-id: https://develop.svn.wordpress.org/trunk@53894 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 22:44:10 +00:00
John Blackbourn
0a2b35180b Taxonomy: Introduce the is_term_publicly_viewable() function.
This is the taxonomy term counterpart to the `is_post_publicly_viewable()` function. Although the logic for terms is more straight forward this serves the same purpose as introducing the corresponding function for posts -- to centralise and reduce the logic needed to validate a term and determine if it's publicly viewable.

Props peterwilsoncc, costdev, johnbillion

Fixes #56215


git-svn-id: https://develop.svn.wordpress.org/trunk@53893 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 22:42:12 +00:00
John Blackbourn
dfcc2f6b18 Editor: Document the arguments for registering a block style.
See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53892 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 22:36:27 +00:00
John Blackbourn
01c9ea7540 Query: Be better at forcing data types for query vars.
Several query vars only accept a scalar value and pass the value through functions that assume a scalar value. Adding extra guard conditions to the types of query vars doesn't affect their functionality but does remove PHP notices and warnings that can otherwise be generated when a non-scalar value such as an array is present in a query var.

Props juliobox, xknown, SergeyBiryukov, dave1010, nacin, tellyworth, dd32, audrasjb, johnregan3

Fixes #17737


git-svn-id: https://develop.svn.wordpress.org/trunk@53891 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 22:29:19 +00:00
Sergey Biryukov
d1e22dbad8 Tests: Bring some consistency to serialization tests.
There were two sets of tests for `is_serialized()`:
* One in the `functions.php` file, based on the same file name in core.
* One in a separate class in the `functions` directory.

To avoid confusion and make it easier to decide where new tests should go in the future, the existing tests are now combined in the latter location.

Includes:
* Moving `is_serialized()` and `maybe_serialize()` tests into their own classes.
* Using named data providers to make test output more descriptive.
* Combining test cases and removing duplicates.

Follow-up to [278/tests], [279/tests], [328/tests], [32631], [45754], [47452], [49382], [53886], [53889].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53890 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 12:09:41 +00:00
Sergey Biryukov
c45ea397da Tests: Use named data provider for is_serialized_string() tests.
This makes the output when using the `--testdox` option more descriptive and is helpful when trying to debug which data set from a data provider failed the test.

Follow-up to [37357], [44478].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53889 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 13:22:25 +00:00
Jb Audras
902530bba9 General: Add required fields helper functions for better reusability.
This changeset introduces new `wp_required_field_indicator()` and `wp_required_field_message()` helper functions to generate reusable and consistent required field indicator and message. It also implements these functions in various admin screens.

Props sabernhardt, ryokuhi, joedolson, audrasjb, SergeyBiryukov.
Fixes #54394.


git-svn-id: https://develop.svn.wordpress.org/trunk@53888 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 12:09:10 +00:00
Jb Audras
e44c3c4fac Docs: Use third-person singular verbs for function descriptions in wp-includes/functions.php, as per docblocks standards.
See #55646.


git-svn-id: https://develop.svn.wordpress.org/trunk@53887 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 09:51:10 +00:00
Jb Audras
38037ebb2c Formatting: Add support for Enums in is_serialized().
This changeset adds support for Enums in `is_serialized()`. It also adds new unit tests for this function.

Props ayeshrajans, konradyoast, peterwilsoncc, costdev, dennisatyoast, mukesh27.
Fixes #53299.


git-svn-id: https://develop.svn.wordpress.org/trunk@53886 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 09:24:23 +00:00
Peter Wilson
c2e2e55b0d Media: Cache parent posts in query-attachments AJAX endpoint.
Prime the parent post objects `wp_ajax_query_attachments()` to reduce the number of database queries in the query-attachments admin-ajax endpoint.

Props albatross10.
Fixes #56037.



git-svn-id: https://develop.svn.wordpress.org/trunk@53885 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 00:15:20 +00:00
Sergey Biryukov
299c8485c0 Login and Registration: Introduce is_login_screen() function.
This should help determine whether the current request is for the login screen.

While it does not save a lot of lines of code, including this function in core aims to save developers some time that would otherwise be spent investigating the most reliable way to solve this problem.

Implementation details:
* By checking `wp_login_url()`, the function accounts for custom login locations set via the `login_url` filter.
* By checking `$_SERVER['SCRIPT_NAME']` directly, instead of `did_action( 'login_form_login' )` or `$pagenow` global, the function can work as early as possible, for example in a must-use plugin.

Follow-up to [2481], [6412], [12393], [12732], [15558], [15481], [15746].

Props dcowgill, scribu, donmhico, iandunn, wonderboymusic, nacin, robmiller, kitchin, chriscct7, tazotodua, davidbaumwald, SergeyBiryukov.
Fixes #19898.

git-svn-id: https://develop.svn.wordpress.org/trunk@53884 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 21:49:08 +00:00
John Blackbourn
40c19e45bf Posts, Post Types: Prevent categories from being overwritten when updating a post using wp_insert_post().
This prevents existing category relationships being overridden with the default category when none is provided in the post data.

Props markoheijnen, leewillis77, desrosj

Fixes #19954


git-svn-id: https://develop.svn.wordpress.org/trunk@53883 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 19:58:21 +00:00
John Blackbourn
7bb8dc6269 Application Passwords: Allow a Super Admin to set an application password on a site they're not a member of.
This removes the requirement that a Super Admin must be a member of the current site when they attempt to set an application password within the admin area of an individual site on the network.

Props TimothyBlynJacobs, ilovecats7, johnbillion, georgestephanis, johnjamesjacoby

Fixes #53224


git-svn-id: https://develop.svn.wordpress.org/trunk@53882 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 18:22:59 +00:00
John Blackbourn
e999a8b281 XML-RPC: Correct the documented arguments for XML-RPC server methods.
See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53881 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:58:55 +00:00
Jonathan Desrosiers
93c52bcb6a Bundled Themes: Remove closing PHP tag at the end of files.
To help avoid issues with trailing whitespace, omitting the closing PHP tag at the end of a file is preferred.

Props netweb, dd32, yahil, milindmore22, vishalkakadiya, NomNom99, manishsongirkar36, sabernhardt, audrasjb, desrosj.
See #40039.

git-svn-id: https://develop.svn.wordpress.org/trunk@53880 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:44:45 +00:00
John Blackbourn
57d6313f33 Docs: Revert two changes that need to instead be made upstream in the Gutenberg repo.
Partially reverts [53877].

See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53879 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:31:59 +00:00
John Blackbourn
8d745ce28d Docs: Miscellaneous inline documentation improvements.
See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53878 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:09:04 +00:00
John Blackbourn
0f1f17ebe2 Docs: Correct and improve the documented types for various functions and hooks.
See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53877 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:01:35 +00:00
John Blackbourn
2b6107d05f Docs: Remove code tags from WordPress function names within inline documentation.
Removing these code tags means the function name will be automatically linked on the developer.wordpress.org reference, which is more useful than just seeing the function name.

See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53876 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 13:53:51 +00:00
Jonathan Desrosiers
134cbc5eaf Twenty Eleven: Correct inline translator comment.
Props sabernhardt.
See #40039.

git-svn-id: https://develop.svn.wordpress.org/trunk@53875 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 13:04:04 +00:00
Pascal Birchler
9c8b1ba9ab I18N: Introduce WP_Textdomain_Registry to store text domains and their language directory paths.
Previously, when using `switch_to_locale()` all current loaded text domains were unloaded and added to the `$l10n_unloaded` global. This prevented the just-in-time loading for text domains after a switch. The just-in-time loading was also only possible if the translations were stored in `WP_LANG_DIR`. Both issues have been fixed.

* Adds `WP_Textdomain_Registry` to keep track of the language directory paths for all plugins and themes.
* Updates all `load_*_textdomain()`  functions to store the path in `WP_Textdomain_Registry`.
* Adds `$locale` parameter to `load_textdomain()` to specify the locale the translation file is for.
* Adds `$reloadable` parameter to `unload_textdomain()` to define whether a text domain can be loaded just-in-time again. This is used by `WP_Locale_Switcher::load_translations()`.
* Extends `_load_textdomain_just_in_time()` to also support text domains of plugins and themes with custom language directories.
* Fixes the incorrect `test_plugin_translation_after_switching_locale_twice()` test which should have caught this issue earlier.
* Adds a new test plugin and theme to test the loading of translations with a custom language directory.
* Deprecates the now unused and private `_get_path_to_translation()` and `_get_path_to_translation_from_lang_dir()` functions.

Previously added in [49236] and reverted in [49236] to investigate concerns which are now addressed here.

Props yoavf, swissspidy, dd32, ocean90.
See #26511.
Fixes #39210.

git-svn-id: https://develop.svn.wordpress.org/trunk@53874 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 12:37:05 +00:00
Jb Audras
6aecbb7f0a Docs: Clarify that register_taxonomy() only accepts lowercase values for the $taxonomy parameter.
This brings consistency with docblock used in `register_post_type()`.

Props audrasjb, bengreeley, dipakparmar443.
Fixes #56352
See #55646.


git-svn-id: https://develop.svn.wordpress.org/trunk@53873 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-10 13:52:42 +00:00
Sergey Biryukov
9b04bb68f1 Coding Standards: Rename the $file parameter to $path in some WP_Filesystem_* methods.
This aims to bring more clarity to the code, and applies to methods where the path can be a file or a directory:

* `WP_Filesystem_*::exists()`
* `WP_Filesystem_*::is_writable()`

Follow-up to [6779], [25560].

See #55647.

git-svn-id: https://develop.svn.wordpress.org/trunk@53872 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-09 11:32:01 +00:00
Jb Audras
1f2f4bc89b Docs: Various docblock fixes in Core Taxonomy API, as per docs standards.
See #55646.


git-svn-id: https://develop.svn.wordpress.org/trunk@53871 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-09 10:39:12 +00:00
Dominik Schilling
ecd5e004f1 Docs: Consistently document the $excluded_terms variable in get_adjacent_post().
The variable `$excluded_terms` is an array of excluded term IDs or empty string if none were provided.

Props grapplerulrich, costdev.
Fixes #56348.

git-svn-id: https://develop.svn.wordpress.org/trunk@53870 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-09 10:29:31 +00:00
Jb Audras
60493f3968 Taxonomy: Prevent non string taxonomy names generating warnings or errors.
This changeset adds an `is_string( $taxonomy )` check to the condition in `taxonomy_exists()`, to ensure `false` is returned when the `$taxonomy` is not a string.

Follow-up to [35718].

Props costdev, peterwilsoncc, mukesh27.
Fixes #56338.
See #56336.


git-svn-id: https://develop.svn.wordpress.org/trunk@53869 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-09 10:21:32 +00:00
Peter Wilson
11cc06cd22 Administration: Improve performance of List Tables.
Improve the performance of `WP_List_Table::get_column_info()` by adding the primary column to the cached header values. This reduces the number of calls to the `WP_List_Table::get_primary_column_name()` method to once per table in line with the other header getter functions.

Props bobbingwide, chaion07, costdev, mikeschroder, mukesh27, peterwilsoncc, shetheliving, spacedmonkey.
Fixes #34564.



git-svn-id: https://develop.svn.wordpress.org/trunk@53868 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-09 00:31:09 +00:00
Andrew Ozz
fdcb89a307 Build/Test Tools: Update @covers tags for the load tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@53867 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 23:42:16 +00:00
Andrew Ozz
f44105103d Build/Test Tools: Add @covers tags to the l10n and i18n tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@53866 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 23:39:06 +00:00
Andrew Ozz
87fc70103d Build/Test Tools: Add @covers tags to the options tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@53865 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 23:33:11 +00:00
Andrew Ozz
a3a926097a Build/Test Tools: Add @covers tags to the import tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@53864 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 23:22:43 +00:00
Andrew Ozz
57b08d1998 Build/Test Tools: Add @covers tags to the comments tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@53863 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 23:12:30 +00:00
Sergey Biryukov
041a9256fb Docs: Improve @since notes for some WP_Filesystem_* methods:
* `WP_Filesystem_FTPext::exists()`
* `WP_Filesystem_FTPext::size()`
* `WP_Filesystem_ftpsockets::exists()`

The `::exists()` methods were previously using the FTP `NLST` command, which works for directories, but is not intended to be applied to a file. This only worked most of the time due to many FTP servers being permissive and allowing to execute `NLST` on files, which cannot be guaranteed and appears to not be the case in newer versions of Pure-FTPd (1.0.48 or later).

With a recent change in [53860], both methods were updated for compatibility with RFC 959:

* Both methods check if the path is a directory that can be changed into (and therefore exists).
* `WP_Filesystem_FTPext` uses `ftp_rawlist()` (FTP `LIST` command) to check for file existence.
* `WP_Filesystem_ftpsockets` uses file size to check for file existence.

Reference: [https://www.ietf.org/rfc/rfc959.txt RFC 959: File Transfer Protocol (FTP)]

Follow-up to [6779], [11821], [25274], [33648], [34733], [35944], [35946], [53860].

See #51170.

git-svn-id: https://develop.svn.wordpress.org/trunk@53862 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 17:12:59 +00:00
Sergey Biryukov
e14d94858f Tests: Improve the test for not throwing a warning on malformed date queries.
* Make it specifically about `wp_resolve_numeric_slug_conflicts()`, the function that was throwing an `Undefined array key "year"` PHP warning for malformed date requests.
* Move the test under the `rewrite` component and make its name a bit more descriptive.
* Check the return result of the function instead of performing a dummy assertion.
* Use named array keys in the data provider for clarity.
* Add missing `@covers` tag.

Follow-up to [32648], [53857].

Props costdev, peterwilsoncc, 1naveengiri, mukesh27, SergeyBiryukov.
See #52252, #45513.

git-svn-id: https://develop.svn.wordpress.org/trunk@53861 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 14:38:08 +00:00
Jb Audras
374052e29a Filesystem: Rewrite FTP/FTP Sockets exists() methods to implement a more stable check.
WordPress FTP file checking was previously based upon `ftp_nlist()`. This function can be problematic at scale with a directory containing a large number of files. The same issue occurred using it with ftpsockets.

This changeset rewrites the FTP `exists()` functions to utilize a more efficient and stable check.

Props giox069, desrosj, mkox, afragen, costdev, pbiron, peterwilsoncc.
Fixes #51170.
See #53318, #39781.


git-svn-id: https://develop.svn.wordpress.org/trunk@53860 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 12:39:51 +00:00
Jb Audras
ba870c487b Docs: Various docblock fixes in wp-includes/blocks.php, as per docs standards.
See #55646.


git-svn-id: https://develop.svn.wordpress.org/trunk@53859 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 08:31:03 +00:00
Jb Audras
0e9917f561 Editor: Safeguard has_blocks() against fatal errors.
This changeset ensures `has_blocks()` doesn't return a fatal error when `$post` is not a valid post. If the post can't be retrieved, the function now returns `false`.

Props Howdy_McGee, costdev, colonelphantom, audrasjb, dlh, peterwilsoncc.
Fixes #55705.


git-svn-id: https://develop.svn.wordpress.org/trunk@53858 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-08 08:20:43 +00:00
Peter Wilson
3e866f8b8f Rewrite rules: Prevent malformed date requests throwing notices.
Ensure that date queries contain each component before attempting to use them. This prevents http requests triggering notices if a portion of the date is missing. For example a request containing a day and year but no month, a request containing a month bu not year.

Props ovidiul, dd32, peterwilsoncc, costdev, johnbillion, SergeyBiryukov, desrosj, tremidkhar, hellofromTonya.
Fixes #52252.



git-svn-id: https://develop.svn.wordpress.org/trunk@53857 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-07 23:03:57 +00:00
Sergey Biryukov
fbfba47f1a Code Modernization: Let MockClass extend stdClass.
This allows for arbitrary properties to be declared on it.

Alternatively, the `MockClass` could be deprecated altogether in favor of directly using `stdClass` where needed.

Follow-up to [53/tests], [65/tests], [53557], [53558], [53850], [53851], [53852], [53853], [53854].

Props jrf.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53856 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-07 16:53:30 +00:00
Sergey Biryukov
025193bd20 Code Modernization: Remove unused $undefined property in Tests_WP_Customize_Manager.
This appears to be a copy/paste from the `Tests_WP_Customize_Setting` class, and is not actually used in `WP_Customize_Manager` tests.

Follow-up to [31329], [32658], [53851].

Props jrf.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53855 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-07 16:36:42 +00:00
Sergey Biryukov
101e686f7a Code Modernization: Remove dynamic properties in Tests_File.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this case, as the `$badchars` property never changes, declaring this as a class constant is the sensible option.

As for the `$dir` property (which cannot be turned into a constant due to the function call), this is used in multiple tests, so making this property explicit makes sense.

Follow-up to [139/tests], [53557], [53558], [53850], [53851], [53852], [53853].

Props jrf.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53854 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-07 14:48:42 +00:00
Sergey Biryukov
278081ed1d Code Modernization: Remove dynamic properties in Tests_Post_Revisions.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular case, the test class contains a `set_up()` method that sets the `$post_type` property, which is ''used'' by the tests, but never ''changed'' by the tests.

In other words, setting this property in the `set_up()` is an unnecessary overhead and the property should be changed to a class constant.

Follow-up to [1212/tests], [52389], [53557], [53558], [53850], [53851], [53852].

Props jrf.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53853 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-07 14:41:04 +00:00
Sergey Biryukov
9d2f309e63 Code Modernization: Remove dynamic properties in Tests_Media_GetPostGalleries.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular case, the test class contains a `set_up()` method that sets the `$img_meta` property, which is ''used'' by the tests, but never ''changed'' by the tests.

In other words, setting this property in the `set_up()` is an unnecessary overhead and the property should be changed to a class constant.

Includes renaming the test class to match the [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization naming conventions].

Follow-up to [52190], [53557], [53558], [53850], [53851].

Props jrf.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53852 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-07 14:32:55 +00:00
Sergey Biryukov
8b98406a17 Code Modernization: Remove unused dynamic property in Tests_WP_Customize_*.
The dynamically created `$undefined` property appears to be a copy/paste from the `Tests_WP_Customize_Setting` class, and is not actually used in other test classes:

* `Tests_WP_Customize_Manager`
* `Tests_WP_Customize_Panel`
* `Tests_WP_Customize_Section`

Follow-up to [31329], [32658].

Props jrf.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53851 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-07 14:20:02 +00:00
Sergey Biryukov
350d5e4590 Code Modernization: Remove dynamic properties in Tests_POMO_PO.
In this particular case, the test class contains a `set_up()` method which sets properties only used by select tests, while the fixture method is being run for all tests.

There were a few ways this could be fixed:
* As the values do not change across tests, use `set_up_before_class()` to set (static) properties instead.
* For those values which are set up without a function call or variable interpolation, set the values in class constants.
* Or set these values as local variables for those tests which actually use them.

The implemented solution is a combination of options 2 and 3.

Follow-up to [1106/tests], [53557], [53558].

Props jrf.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53850 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-07 13:56:35 +00:00
Sergey Biryukov
d6b46b9b99 Tests: Rename the test class for wp_preload_resources() tests.
This matches the name of the function being tested.

Follow-up to [53846].

See #42438.

git-svn-id: https://develop.svn.wordpress.org/trunk@53849 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-06 00:03:01 +00:00