Commit Graph

44378 Commits

Author SHA1 Message Date
Sergey Biryukov
ab110d5206 Tests: Replace assertNotRegExp() with assertDoesNotMatchRegularExpression().
The `assertRegExp()` and `assertNotRegExp()` methods were hard deprecated in PHPUnit 9.1 and the functionality will be removed in PHPUnit 10.0.

The `assertMatchesRegularExpression()` and `assertDoesNotMatchRegularExpression()` methods were introduced as a replacement in PHPUnit 9.1.

These new PHPUnit methods are polyfilled by the PHPUnit Polyfills and switching to them will future-proof the tests some more.

References:
* https://github.com/sebastianbergmann/phpunit/blob/9.1.5/ChangeLog-9.1.md#910---2020-04-03
* https://github.com/sebastianbergmann/phpunit/issues/4085
* https://github.com/sebastianbergmann/phpunit/issues/4088

Follow-up to [51559-51565].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51177 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-06 21:56:57 +00:00
Sergey Biryukov
0aacd6abfd Tests: Replace assertRegExp() with assertMatchesRegularExpression().
The `assertRegExp()` and `assertNotRegExp()` methods were hard deprecated in PHPUnit 9.1 and the functionality will be removed in PHPUnit 10.0.

The `assertMatchesRegularExpression()` and `assertDoesNotMatchRegularExpression()` methods were introduced as a replacement in PHPUnit 9.1.

These new PHPUnit methods are polyfilled by the PHPUnit Polyfills and switching to them will future-proof the tests some more.

References:
* https://github.com/sebastianbergmann/phpunit/blob/9.1.5/ChangeLog-9.1.md#910---2020-04-03
* https://github.com/sebastianbergmann/phpunit/issues/4085
* https://github.com/sebastianbergmann/phpunit/issues/4088

Follow-up to [51559-51564].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51176 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-06 21:53:57 +00:00
Sergey Biryukov
549857fa3b Tests: Replace assertFileNotExists() with assertFileDoesNotExist().
The `assertFileNotExists()` method was hard deprecated in PHPUnit 9.1 and the functionality will be removed in PHPUnit 10.0.

The `assertFileDoesNotExist()` method was introduced as a replacement in PHPUnit 9.1.

This new PHPUnit method is polyfilled by the PHPUnit Polyfills and switching to it will future-proof the tests some more.

References:
* https://github.com/sebastianbergmann/phpunit/blob/9.1.5/ChangeLog-9.1.md#910---2020-04-03
* https://github.com/sebastianbergmann/phpunit/issues/4076

Follow-up to [51559-51563].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-06 21:46:55 +00:00
Sergey Biryukov
9a8caf2eba Tests: Replace expectException() for PHP native errors with calls to the dedicated PHPUnit 8.4+ methods.
The old manner of testing these is soft deprecated as of PHPUnit 8.4, hard deprecated as of PHPUnit 9.0 and will be removed in PHPUnit 10.0.

These dedicated methods introduced in PHPUnit 8.4 should be used as an alternative:

* `expectDeprecation()`
* `expectDeprecationMessage()`
* `expectDeprecationMessageMatches()`
* `expectNotice()`
* `expectNoticeMessage()`
* `expectNoticeMessageMatches()`
* `expectWarning()`
* `expectWarningMessage()`
* `expectWarningMessageMatches()`
* `expectError()`
* `expectErrorMessage()`
* `expectErrorMessageMatches()`

These new PHPUnit methods are all polyfilled by the PHPUnit Polyfills and switching to these will future-proof the tests some more.

References:
* https://github.com/sebastianbergmann/phpunit/blob/8.4.3/ChangeLog-8.4.md#840---2019-10-04
* https://github.com/sebastianbergmann/phpunit/issues/3775

Follow-up to [51559-51562].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51174 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-06 21:39:58 +00:00
Sergey Biryukov
23383ec51c Build/Test Tools: Simplify redundant PHPUnit shim for setExpectedException().
PHPUnit 6 deprecated the `setExpectedException()` method in favor of the `expectException()`, `expectExceptionMessage()`, and `expectExceptionCode()` methods.

`WP_UnitTestCase_Base::setExpectedException()` backfilled the old method. As the PHPUnit Polyfills have a polyfill for the ''new'' method, this backfill can now be simplified.

This backfill ''should'' be removed in a future iteration, but is, for now, left in place so as not to break backward compatibility for plugin/theme test suites which extend the WP native test suite for their integration tests.

Follow-up to [48996], [48997], [51559-51561].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51173 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-06 21:19:02 +00:00
Sergey Biryukov
46ef4c1f7b Build/Test Tools: Change the inheritance order of the abstract test classes.
As things were, the inheritance order of the abstract test classes was as follows:
{{{
WP_UnitTestCase (PHPUnit adapter layer)
    extends WP_UnitTestCase_Base (base test class)
        extends PHPUnit\Framework\TestCase (PHPUnit native class)
}}}

Concrete (child) test classes, as well as more specific abstract TestCases, are/were expected to extend the `WP_UnitTestCase`.

This order is not optimal as it means that the `WP_UnitTestCase_Base` class would not be able to benefit from any polyfills and/or shims in the PHPUnit adapter layer.

With that in mind, this commit changes the inheritance to:
{{{
WP_UnitTestCase (empty class, left in place to not break BC for plugin/theme integration tests)
    extends WP_UnitTestCase_Base (base test class)
        extends PHPUnit_Adapter_TestCase (PHPUnit adapter layer)
            extends PHPUnit\Framework\TestCase (PHPUnit native class)
}}}

The new order allows for the `WP_UnitTestCase_Base` to also benefit from the PHPUnit adapter layer.

For backward compatibility reasons the `WP_UnitTestCase`, which all test classes are (were) expected to extend, is left in place, though it is now an empty class and explicitly `abstract`.

Follow-up to [51559], [51560].

Props jrf, hellofromTonya, johnbillion, netweb, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51561


git-svn-id: http://core.svn.wordpress.org/trunk@51172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-06 00:44:57 +00:00
Sergey Biryukov
afea9cfbd6 Build/Test Tools: Unify the PHPUnit adapter TestCases.
This commit:
* Removes the PHPUnit 7 specific `TestCase`.
* Removes all existing polyfills from the PHPUnit 5.x `TestCase`.
* Imports all polyfill traits from the PHPUnit Polyfills package into the `WP_UnitTestCase` class and updates the DocBlock to reflect the actual function of the class.
 * Note: The list of polyfills needs to be verified and updated after each new release of the PHPUnit Polyfills package. Alternatively (recommended), one of the built-in `TestCase` classes from the PHPUnit Polyfills package can be used instead.

* Moves the `require` for the WP `abstract-testcase.php` to the `bootstrap.php` file.
* Adds a `require_once` for the PHPUnit Polyfills autoloader to the `bootstrap.php` file.
 * Note: while this isn't _strictly_ necessary when the tests are run via Composer, having the include in the bootstrap allows for the tests to also be run via a PHPUnit Phar, providing contributors with more flexibility.

Follow-up to [51559].

Props jrf, hellofromTonya, johnbillion, netweb, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51560


git-svn-id: http://core.svn.wordpress.org/trunk@51171 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-06 00:36:56 +00:00
Sergey Biryukov
b39d6ce7ad Build/Test Tools: Add Composer dependency on the PHPUnit Polyfills package.
The PHPUnit Polyfills package is an add-on for PHPUnit, which works around common issues for writing PHPUnit cross-version compatible tests.

Features:
* It offers a full set of polyfills for assertions and expectations introduced in PHPUnit since PHPUnit 4.8.
* It offers two generic TestCases which include these polyfills, but also solve the `void` return type issue for the fixtures methods.
* It offers a PHPUnit cross-version solution for the changes to the PHPUnit `TestListener` implementation.
* Supports PHPUnit 4.8 – current.
* Supports and is compatible with PHP 5.4 – current.

The package has no outside dependencies, other than PHPUnit, is actively maintained and endorsed by the maintainer of PHPUnit itself (the only package of its kind which has ever been endorsed).

Props jrf, hellofromTonya, johnbillion, netweb, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51559


git-svn-id: http://core.svn.wordpress.org/trunk@51170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-06 00:34:58 +00:00
desrosj
fa93063ac1 Build/Test Tools: Add branch filtering for Slack notifications workflow.
Since branch filtering happens prior to the workflow run being created, filtering the branches that `workflow_run` will fire on for this workflow should cut down on the number of skipped “Slack Notifications” runs listed in the Actions section of the repository.

This also removes the check for a `skipped` outcome in the requesting workflow. Workflows for push events resulting from WordPress Core commits are never skipped.

See #52644.
Built from https://develop.svn.wordpress.org/trunk@51558


git-svn-id: http://core.svn.wordpress.org/trunk@51169 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 16:53:55 +00:00
Sergey Biryukov
04f4e911dc Coding Standards: Silence a WPCS warning in date_i18n().
This fixes a "Calling `current_time()` with a `$type` of `timestamp` or `U` is strongly discouraged as it will not return a Unix (UTC) timestamp" warning.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51168 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 14:49:57 +00:00
Sergey Biryukov
62a788e40e Twenty Thirteen: Correct indentation in image.php template.
Props jrf.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51556


git-svn-id: http://core.svn.wordpress.org/trunk@51167 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 14:38:57 +00:00
desrosj
3560a816d5 Build/Test Tools: Correctly check for the trigger event when running the Slack notifications workflow.
This updates the conditional check for the Slack notifications workflow to check the event of the original workflow and not the one requested through the `workflow_run:completed` event.

The run triggering the event is accessible at `github.event.workflow_run`.

Props Clorith.
See #52644.
Built from https://develop.svn.wordpress.org/trunk@51555


git-svn-id: http://core.svn.wordpress.org/trunk@51166 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 14:37:56 +00:00
Sergey Biryukov
ee4be502a7 Twenty Thirteen: Remove wrapping HTML tag from translatable string.
This fixes a "Strings should not be wrapped in HTML" WPCS warning.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51165 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 14:36:57 +00:00
Sergey Biryukov
64b193980a Bundled Themes: Remove redundant semicolons after closing curly brackets.
Includes a few minor indentation fixes.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51164 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 13:25:58 +00:00
Sergey Biryukov
815e31f611 Coding Standards: Remove redundant semicolons after closing curly brackets.
Props jrf.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51552


git-svn-id: http://core.svn.wordpress.org/trunk@51163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 13:15:55 +00:00
Sergey Biryukov
d289b7f602 Coding Standards: Fix incorrect alignment in two comment blocks.
Tabs should only be used for indentation and not for mid-line alignment.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51162 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 13:11:56 +00:00
Sergey Biryukov
72acd346a2 Coding Standards: Fix incorrect comment indent in safecss_filter_attr().
Props jrf.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51550


git-svn-id: http://core.svn.wordpress.org/trunk@51161 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 12:59:58 +00:00
Peter Wilson
73be6fd8ef Coding Standards: Use strict comparisons in wp-admin/upload.php.
See #53359.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51160 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 03:37:56 +00:00
Peter Wilson
c1d05d5085 Coding Standards: Use strict comparisons in wp-admin/options-discussion.php.
See #53359.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-05 03:30:57 +00:00
Sergey Biryukov
318fc1fcc9 Build/Test Tools: Switch to always running the tests via Composer.
Previously the tests were run via a PHPUnit Phar file for PHP 5.6–7.4, with PHP 8.0 using a Composer-installed version of PHPUnit.

Running the tests via a Phar without the need for a `composer install` is (marginally) faster in overall build time, however, this commit is part of a larger chain of changes which will make the test suite PHPUnit cross-version compatible.

With an eye on those upcoming changes, which will allow us to run the tests on the most appropriate PHPUnit version for each supported PHP version, it is opportune to switch to using a Composer-installed version of PHPUnit for all PHP versions supported by WordPress. Previously this was not possible without additional conditional `update` commands being run, due to the `composer.lock` file being in place and being locked at PHPUnit 7.5.20.

Switching over to using the Composer-installed PHPUnit version, with that PHPUnit version adjusting based on the PHP version, allows for some minor simplifications in the GitHub Actions script.

This means we need additional measures to make sure that the Composer cache file does not go too far out of date as that would significantly slow down the builds.

By adding a "Last Monday" date to the cache key, in combination with the pre-existing OS, PHP version and the hash of the `composer.json` file, we can guarantee that:
1. There will be a cache created for each OS/PHP combination.
2. These caches will be replaced whenever a change is made to the `composer.json` file.
3. These caches will be replaced every Monday of each week ensuring that the cache file does not go too far out of date.

Note: The NPM script `test:php` is now no longer needed during the builds. However, to prevent breaking the workflow of contributors who may be used to having the command available, the command remains available.

In a future iteration we may be able to replace the caching of the Composer dependencies with the Composer cache action as offered on the GitHub marketplace, which would further simplify the script.

Follow-up to [42960], [46290], [47881], [48957], [49037], [51543], [51544].

Props jrf, desrosj.
Fixes #47381.
Built from https://develop.svn.wordpress.org/trunk@51545


git-svn-id: http://core.svn.wordpress.org/trunk@51156 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-04 19:49:56 +00:00
Sergey Biryukov
3db37d3459 Build/Test Tools: Use a custom autoloader for the PHPUnit 9.x mock object classes.
This prevents the classes from being loaded automatically via the `autoload-dev` directives when a Composer-installed PHPUnit 5.x or 6.x version is used, as that would break the test run.

It is expected that this autoloader will be removed soon, as it should no longer be needed when the PHPUnit version constraints are widened.

Notes:
* The autoloader file will be loaded from the Test bootstrap.
* The autoloader will always be registered and directed to queue itself _before_ the Composer autoload file (which will already have been registered).
* The autoloader will only actually load the WP copies of the files/classes when PHP 8.0 in combination with PHPUnit 7.x is detected. In all other cases, the autoloader will bow out, which effectively then defers to the Composer autoload file to load the files as shipped with the installed PHPUnit version.

Follow-up to [48957], [49037], [51543].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51155 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-04 19:26:00 +00:00
Sergey Biryukov
6e4d0d8f48 Build/Test Tools: Remove the Composer lock file from version control.
This makes it easier to run unit tests against multiple different PHP versions.

There is currently no reason to have a `composer.lock` file as:

* External runtime dependencies are not managed via Composer.
* Managed updates of the non-runtime dependencies can be done by locking the version used in the `composer.json` file to a precise version instead of using a `composer.lock` file.
* Having the `composer.lock` file in place makes it a lot more difficult to run the tests against all supported PHP versions.

With these considerations in mind, the lock file is now removed from version control and added to `.gitignore` and `svn:ignore`.

Version constraints for the current dev dependencies are adjusted accordingly:

* PHPUnit now explicitly declares in its version constraints that PHPUnit 5.x, 6.x, and 7.x are supported. The minimum supported version for PHPUnit 5.x has been raised from 5.4 to 5.7, which in practice was already the version used for running the tests on PHP 5.6.
* PHPCompatibilityWP is effectively updated to version 2.1.2 with the positive impact that a few new constants polyfilled in WP 5.8 are now accounted for (excluded from being flagged).
* PHP_CodeSniffer is declared as an explicit dependency to ensure that updates to it will always be explicitly managed instead of inherited.
* The DealerDirect Composer plugin is effectively updated to version 0.7.1 without impact.

Follow-up to [42960], [46290], [47881], [48957].

Props jrf, johnbillion, desrosj, ayeshrajans, aristath, hellofromTonya, SergeyBiryukov.
See #47381.
Built from https://develop.svn.wordpress.org/trunk@51543


git-svn-id: http://core.svn.wordpress.org/trunk@51154 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-04 18:57:00 +00:00
Sergey Biryukov
8f994d84de Media: Add / character to <img> tag in wp_print_media_templates().
While this has no effect on void elements in HTML5, it fixes a minor inconsistency with the rest of core.

Follow-up to [47493], [48834], [50556], [51473], [51541].

Props shital-patel, akabarikalpesh.
Fixes #53870.
Built from https://develop.svn.wordpress.org/trunk@51542


git-svn-id: http://core.svn.wordpress.org/trunk@51153 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-04 14:25:58 +00:00
Sergey Biryukov
0be77d4ebf Bundled Themes: Add / character to <img> tags.
While this has no effect on void elements in HTML5, it fixes a minor inconsistency with the rest of core.

Follow-up to [47493], [48834], [50556], [51473].

Props shital-patel, akabarikalpesh.
See #53870.
Built from https://develop.svn.wordpress.org/trunk@51541


git-svn-id: http://core.svn.wordpress.org/trunk@51152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-04 14:24:02 +00:00
Peter Wilson
67119713fc Editor: Prevent block-editor JavaScript loading in other editors.
Add a check to `wp_add_iframed_editor_assets_html()` confirming the edit post screen is using the block-editor before including block-editor specific JavaScript. For the classic and other editors the function returns early without any output.

Props swissspidy, desrosj.
Fixes #53696.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51151 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-04 05:10:56 +00:00
Peter Wilson
7829821c62 Menus: Hide bulk-select on new menu page.
Prevent the bulk-select option from displaying when adding a new menu. This also prevents the option from displaying when an administrator first visits the menu page and no menus are set.

Props dlh, sabernhardt.
Fixes #53654.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51150 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-04 05:00:59 +00:00
jorgefilipecosta
eff1c81de6 Block Editor: Add missing border setting on button block.
This commit fixes a regression on WordPress 5.8 that made the border radius setting on the buttons block disappear.

Props Mamaduka, daisyo, priethor, desrosj, mikeschroder.
Fixes #53702.
Built from https://develop.svn.wordpress.org/trunk@51538


git-svn-id: http://core.svn.wordpress.org/trunk@51149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 18:14:58 +00:00
desrosj
cf0f278ebe Build/Test Tools: Revert changes only included for testing purposes.
Follow up to [51535-51536].

See #52644.
Built from https://develop.svn.wordpress.org/trunk@51537


git-svn-id: http://core.svn.wordpress.org/trunk@51148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 15:15:57 +00:00
desrosj
f45ed61786 Build/Test Tools: Correct invalid JSON in Slack payload.
The outer `”` marks are not required and produce invalid JSON.

See #52644.
Built from https://develop.svn.wordpress.org/trunk@51536


git-svn-id: http://core.svn.wordpress.org/trunk@51147 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 15:08:56 +00:00
desrosj
a748075471 Build/Test Tools: Expand Slack notifications for GitHub Actions.
This expands Slack notifications to include success, cancelled, and “fixed” GitHub Action workflow run outcomes in addition to failures.

A “fixed” outcome occurs when the previous run for a workflow failed and the current one succeeds. This matches the behavior that was native to TravisCI by setting `on_success` for notifications to `change`.

The message details and where each outcome is posted is controlled by Slack workflows.

The Slack notification logic has also been pulled into a separate workflow to prevent repeating code in every workflow.

See #52644.
Built from https://develop.svn.wordpress.org/trunk@51535


git-svn-id: http://core.svn.wordpress.org/trunk@51146 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 13:46:56 +00:00
Sergey Biryukov
def9fc3741 Coding Standards: Correct DateTimeZone class name in WP_Customize_Date_Time_Control::get_timezone_info().
Follow-up to [41626].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51534


git-svn-id: http://core.svn.wordpress.org/trunk@51145 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 12:18:57 +00:00
Sergey Biryukov
5400c50367 Code Modernization: Pass correct default value to new DateTime() in wp_default_packages_inline_scripts().
This fixes a "Deprecated: `DateTime::__construct()`: Passing null to parameter #1 (`$datetime`) of type string is deprecated" warning on PHP 8.1.

Follow-up to [49083].

See #53635.
Built from https://develop.svn.wordpress.org/trunk@51533


git-svn-id: http://core.svn.wordpress.org/trunk@51144 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 12:04:58 +00:00
Sergey Biryukov
fedcc33d27 Code Modernization: Silence the deprecation warnings for missing return type in WP_Block_List.
This fixes the "Deprecated: Return type of `WP_Block_List::[METHODNAME]()` should be compatible with `ArrayAccess::[METHODNAME](): type`" warnings on PHP 8.1.

PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration), or need to silence the deprecation warning using the `#[ReturnTypeWillChange]` attribute.

Follow-up to [51517], [51529], [51530], [51531].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 11:12:55 +00:00
Sergey Biryukov
68ba315d9a Code Modernization: Silence the deprecation warnings for missing return type in WP_REST_Request.
This fixes the "Deprecated: Return type of `WP_REST_Request::[METHODNAME]($offset)` should be compatible with `ArrayAccess::[METHODNAME](): type`" warnings on PHP 8.1.

PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration), or need to silence the deprecation warning using the `#[ReturnTypeWillChange]` attribute.

Follow-up to [51517], [51529], [51530].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 11:08:56 +00:00
Sergey Biryukov
85c1413c2b Code Modernization: Silence the deprecation warnings for missing return type in WP_Hook.
This fixes the "Deprecated: Return type of `WP_Hook::[METHODNAME]()` should be compatible with `ArrayAccess::[METHODNAME](): type`" warnings on PHP 8.1.

PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration), or need to silence the deprecation warning using the `#[ReturnTypeWillChange]` attribute.

Follow-up to [51517], [51529].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51141 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 11:02:00 +00:00
Sergey Biryukov
3c14324dc6 Code Modernization: Silence the deprecation warnings for missing return type in WP_Theme.
This fixes the "Deprecated: Return type of `WP_Theme::[METHODNAME]($offset)` should be compatible with `ArrayAccess::[METHODNAME](): type`" warnings on PHP 8.1.

PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration), or need to silence the deprecation warning using the `#[ReturnTypeWillChange]` attribute.

Follow-up to [51517].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51140 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-02 22:31:56 +00:00
Sergey Biryukov
9a4280c75f Upgrade/Install: Store correct result when bulk updating plugins or themes.
This ensures that when multiple plugins or themes are updated and one succeeds and another fails, the error is reported accordingly.

Previously, both updates would end up treated as a success, due to `$this->result` containing the result of the previous operation and not the current one.

Follow-up to [12097].

Props pwtyler, afragen.
Fixes #53002.
Built from https://develop.svn.wordpress.org/trunk@51528


git-svn-id: http://core.svn.wordpress.org/trunk@51139 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-02 20:55:56 +00:00
Sergey Biryukov
b186e19855 Docs: Fix typo in the WP_Upgrader::install_package() description.
Follow-up to [30758].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51527


git-svn-id: http://core.svn.wordpress.org/trunk@51138 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-02 18:27:57 +00:00
Sergey Biryukov
2e707307d9 Coding Standards: Fix typo in the JS function name for handling the password reset button.
Follow-up to [50129].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51526


git-svn-id: http://core.svn.wordpress.org/trunk@51137 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-02 16:48:57 +00:00
Sergey Biryukov
47fc56d650 Upgrade/Install: Avoid creating nonce during installation.
This avoids a "Table `wp_options` doesn't exist" database error when trying to create a nonce for password reset button.

When installing and using database-saved salts, `wp_create_nonce()` causes database errors as `wp_salt()` attempts to insert into the not-yet-created options table. Since authentication is not available during installation, we can safely skip creating a nonce.

Follow-up to [39684], [50129].

Props schlessera, swissspidy, sanketchodavadiya, hellofromTonya, SergeyBiryukov.
Fixes #53830.
Built from https://develop.svn.wordpress.org/trunk@51525


git-svn-id: http://core.svn.wordpress.org/trunk@51136 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-02 16:39:00 +00:00
Sergey Biryukov
9e33977bc9 Themes: Make sure get_theme_mods() always returns an array.
This avoids a "Cannot access offset of type string on string" fatal error in `set_theme_mod()` on PHP 8 if the `theme_mods_$theme_slug` option has an incorrect value, e.g. an empty string instead of an array.

With this change, `set_theme_mod()` should be able to resolve the issue by saving a correct value.

Follow-up to [15736], [15739], [30672], [32629], [32632].

Props xknown.
See #51423.
Built from https://develop.svn.wordpress.org/trunk@51524


git-svn-id: http://core.svn.wordpress.org/trunk@51135 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-01 14:55:56 +00:00
Sergey Biryukov
963dd5f06d Docs: Document the $wpdb global in WP_Debug_Data::get_mysql_var().
Follow-up to [51522].

See #53845.
Built from https://develop.svn.wordpress.org/trunk@51523


git-svn-id: http://core.svn.wordpress.org/trunk@51134 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-01 14:04:56 +00:00
Sergey Biryukov
2a0191b901 Site Health: Add some more MySQL information to the Site Health Info screen.
This adds three values to the debug info in the Database section:

* Max allowed packet size
* Max connections number
* Query cache size

Props zodiac1978, donmhico, mukesh27, SergeyBiryukov.
Fixes #53845.
Built from https://develop.svn.wordpress.org/trunk@51522


git-svn-id: http://core.svn.wordpress.org/trunk@51133 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-01 14:02:00 +00:00
Sergey Biryukov
aa0ed0fcdd Upgrade/Install: Skip any node_modules directories when removing Genericons example.html files on update.
This can significantly reduce the time required to complete the process in a development environment.

Follow-up to [32386].

Props bobbingwide, afragen, desrosj, SergeyBiryukov.
Fixes #52765.
Built from https://develop.svn.wordpress.org/trunk@51521


git-svn-id: http://core.svn.wordpress.org/trunk@51132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-31 10:32:56 +00:00
Sergey Biryukov
4889679ca5 Taxonomy: Pass correct default value for $post_id to wp_terms_checklist() in the posts list table.
This matches the documented type of the `$post_id` argument and is consistent with other instances of `wp_terms_checklist()` calls.

Per the function documentation, the default value is integer `0`, not `null`.

Follow-up to [13535].

Props tareiking, donmhico, jrf.
Fixes #43639.
Built from https://develop.svn.wordpress.org/trunk@51520


git-svn-id: http://core.svn.wordpress.org/trunk@51131 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-31 09:50:57 +00:00
John Blackbourn
8935467410 Site Health: Standardise site health check status message punctuation.
Fixes #53594

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


git-svn-id: http://core.svn.wordpress.org/trunk@51130 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-30 19:38:57 +00:00
John Blackbourn
2cb4ebefe2 Docs: Replace $this in hook param docs with more appropriate names.
`$this` is a pseudo-variable that cannot be used as the name of a function parameter, so renaming these helps prevent errors when implementing hook callback functions.

Fixes #53457

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


git-svn-id: http://core.svn.wordpress.org/trunk@51129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-30 19:35:58 +00:00
Sergey Biryukov
166dc3ac8e Code Modernization: Fix "JsonSerializable_Object::jsonSerialize() should be compatible with JsonSerializable::jsonSerialize(): mixed" error on PHP 8.1.
This relates to the [https://wiki.php.net/rfc/internal_method_return_types Return types for internal methods RFC] in PHP 8.1 and in particular, the change made in [https://github.com/php/php-src/pull/7051 PHP PR #7051], which adds a `mixed` return type to the `JsonSerializable::jsonSerialize()` interface method.

WordPress only contains one (test) class which implements the `JsonSerializable` interface and this commit fixes the issue for that class.

As of PHP 8.1, the `jsonSerialize()` method in classes which implement the `JsonSerializable` interface are expected to have a return type declared. The return type should be `mixed` or a more specific type. This complies with the Liskov principle of covariance, which allows the return type of a child overloaded method to be more specific than that of the parent.

The problem with this is that:
1. The `mixed` return type was only introduced in PHP 8.0.
2. Return types in general were only introduced in PHP 7.0.

WordPress still has a minimum PHP version of 5.6, so adding the return type is not feasible for the time being.

The solution chosen for now is to add an attribute to silence the deprecation warning. While attributes are a PHP 8.0+ feature, due to the choice of the `#[]` syntax, in PHP < 8.0, attributes will just be ignored and treated as comments, so there is no drawback to using the attribute.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51128 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-30 14:47:57 +00:00
John Blackbourn
a4bdae8122 Docs: Add missing documentation for the minute parameter of WP_Query.
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51125 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-30 10:53:58 +00:00
John Blackbourn
ab9ed33f1d Docs: Correct the documented allowed range for the minute and second parameters of WP_Query.
These are correctly documented and validated in `WP_Date_Query` as 0-59.

See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51124 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-30 10:23:57 +00:00