Commit Graph

13 Commits

Author SHA1 Message Date
Sergey Biryukov
1ce5dc7444 Code Modernization: Replace usage of strpos() with str_contains().
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).

WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.

This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.

Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].

Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes #58206.
Built from https://develop.svn.wordpress.org/trunk@55988


git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 14:36:26 +00:00
Sergey Biryukov
a0163f91d4 Code Modernization: Explicitly declare all properties in WP_Ajax_Upgrader_Skin.
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, the `$plugin_info` and `$theme_info` properties are set in `Plugin_Upgrader::bulk_upgrade()` and `Theme_Upgrader::bulk_upgrade()` specifically.

The `Bulk_Plugin_Upgrader_Skin` class and the `Bulk_Theme_Upgrader_Skin` class both already allow for this, but the `wp_ajax_update_plugin()` and `wp_ajax_update_theme()` functions also call the `*_Upgrader::bulk_upgrade()` methods, so the `WP_Ajax_Upgrader_Skin` class also needs to have these properties explicitly declared.

Includes adding proper DocBlocks for the pre-existing properties in the `Bulk_Plugin_Upgrader_Skin` and the `Bulk_Theme_Upgrader_Skin` classes.

Follow-up to [13686], [37714], [38199], [42677], [42873], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942], [53945], [53948], [53949].

Props jrf, costdev.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53952


git-svn-id: http://core.svn.wordpress.org/trunk@53511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-29 12:46:10 +00:00
hellofromTonya
03331f52ff Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in WP_Upgrader_Skin::feedback().
In the parent class, renames the parameter `$string` to `$feedback`.
Why? `string` is a PHP reserved keyword.

In each child class: renames the parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51781


git-svn-id: http://core.svn.wordpress.org/trunk@51388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 13:48:56 +00:00
Sergey Biryukov
185607c417 Docs: Add missing descriptions for Automatic_Upgrader_Skin methods.
Props johannadevos, dilipbheda.
Fixes #44546.
Built from https://develop.svn.wordpress.org/trunk@49596


git-svn-id: http://core.svn.wordpress.org/trunk@49334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-14 16:23:10 +00:00
Sergey Biryukov
0dd2f9f5c5 Docs: Add missing documentation for various upgrade/install class properties and methods.
Props ramiy.
Fixes #42923.
Built from https://develop.svn.wordpress.org/trunk@48661


git-svn-id: http://core.svn.wordpress.org/trunk@48423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-28 11:57:03 +00:00
Sergey Biryukov
8d1e51e9c7 Docs: Add a @since note about new parameters with the spread operator added to function signatures.
Props jrf.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46451


git-svn-id: http://core.svn.wordpress.org/trunk@46249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-09 04:28:02 +00:00
Sergey Biryukov
340b7b53c8 Code Modernisation: Introduce the spread operator in wp-admin/includes/class-*-upgrader-skin.php.
Rather than relying `func_get_args()` to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable.

Props jrf.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46125


git-svn-id: http://core.svn.wordpress.org/trunk@45937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-15 10:42:54 +00:00
Sergey Biryukov
13da094c39 Upgrade/Install: Correct operator precedence for an error code in WP_Ajax_Upgrader_Skin::error().
Props jrf.
Fixes #47441.
Built from https://develop.svn.wordpress.org/trunk@45487


git-svn-id: http://core.svn.wordpress.org/trunk@45298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-31 14:14:52 +00:00
Sergey Biryukov
0e802a627d General: Introduce WP_Error::has_errors() method and use it where appropriate.
Props robdxw, DrewAPicture, SergeyBiryukov.
Fixes #42742.
Built from https://develop.svn.wordpress.org/trunk@42761


git-svn-id: http://core.svn.wordpress.org/trunk@42591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-27 02:31:31 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Drew Jaynes
1a28ec87e1 Docs: Remove @access notations from method DocBlocks in wp-admin/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.

Built from https://develop.svn.wordpress.org/trunk@41161


git-svn-id: http://core.svn.wordpress.org/trunk@41001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 00:40:43 +00:00
Sergey Biryukov
c7feb8387a Upgrade/Install: In WP_Ajax_Upgrader_Skin, call ::get_error_codes() method on a WP_Error object $this->errors instead of a string variable $errors.
Props yrpwayne.
Fixes #41449.
Built from https://develop.svn.wordpress.org/trunk@41157


git-svn-id: http://core.svn.wordpress.org/trunk@40997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-26 13:39:44 +00:00
Dominik Schilling
58d772a02f Upgrade/Install: Make some install/update failures more verbose.
An upgrader class is used in conjunction with an upgrader skin class. A skin class handles the logging for an upgrade and informs a user about the progress and failures.
The current Ajax install/update handlers are using the `Automatic_Upgrader_Skin` class because during an Ajax request no output is intended. The difference between Ajax updates and automatic updates is that you will see the full log (usually by email) while Ajax updates focus only on success or failure. For that `Automatic_Upgrader_Skin` has one disadvantage: It doesn't provide a way to retrieve failure messages which were passed through `WP_Upgrader_Skin::error()` by the upgrader.
To solve this issue a new skin `WP_Ajax_Upgrader_Skin` has been introduced. The skin extends `Automatic_Upgrader_Skin` and overrides the `error()` and `feedback()` methods to intercept all errors, which can be a `WP_Error` object or a string.

This updates all four Ajax handler for installing/updating themes/plugins to use the new skin. They now also check the skin for any intercepted errors and pass them on to the user.

Props flixos90, obenland, ocean90.
Props DrewAPicture, pento for review.
Fixes #37531.
Built from https://develop.svn.wordpress.org/trunk@38199


git-svn-id: http://core.svn.wordpress.org/trunk@38140 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-04 22:18:30 +00:00