-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP 8.1 / 8.2 Compatibility #7225
Conversation
- php: '8.2' wp: 'trunk' experimental: true
Using floats as array keys is deprecated in PHP 8.1
* origin/develop: (32 commits) Bump classnames from 2.3.1 to 2.3.2 Bump webpack-remove-empty-scripts from 1.0.0 to 1.0.1 Bump wp-cli/extension-command from 2.1.6 to 2.1.7 Bump postcss-preset-env from 7.8.1 to 7.8.2 Update jest snapshots after @wordpress/components package updates Update Gutenberg package dependencies Bump sirbrillig/phpcs-variable-analysis from 2.11.7 to 2.11.8 Fix failing tests on trunk due to webp support Remove avoidable isset() check Bump @babel/core from 7.18.13 to 7.19.0 Bump eslint from 8.23.0 to 8.23.1 Bump eslint-plugin-jest from 27.0.1 to 27.0.4 Bump eslint-plugin-react from 7.31.1 to 7.31.8 Bump webpack-remove-empty-scripts from 0.8.1 to 1.0.0 Bump css-minimizer-webpack-plugin from 4.0.0 to 4.1.0 Update Gutenberg package dependencies Bump postcss-preset-env from 7.8.0 to 7.8.1 Update test snapshots Update mask-type attribute with mask-type css prop Bump uuid from 8.3.2 to 9.0.0 ...
Co-authored-by: Weston Ruter <[email protected]>
Something to fix in PHP-CSS-Parser:
|
FYI, while GB 14.4 was released today, that bugfix won't be included until version 14.5 (due by November 07, 2022) |
This required status check needs to be removed/changed, since now the coverage is done with PHP 8.0 instead. |
Removed (to be changed after merge) |
* @param string $header_value Header value. | ||
* @return bool Whether header contains the value "hit" | ||
*/ | ||
private static function cache_hit_callback( string $header_value ): bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was introduced in bd2ee42 apparently to deal with a PHPCS bug, and not due to any fault of the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
// Detect where to load the WordPress tests environment from. | ||
if ( false !== getenv( 'WP_TESTS_DIR' ) ) { | ||
$_test_root = getenv( 'WP_TESTS_DIR' ); | ||
} elseif ( false !== getenv( 'WP_DEVELOP_DIR' ) ) { | ||
$_test_root = getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit'; | ||
} elseif ( file_exists( '/tmp/wordpress-tests/includes/bootstrap.php' ) ) { | ||
$_test_root = '/tmp/wordpress-tests'; | ||
} elseif ( file_exists( '/var/www/wordpress-develop/tests/phpunit' ) ) { | ||
$_test_root = '/var/www/wordpress-develop/tests/phpunit'; | ||
} else { | ||
$_test_root = dirname( dirname( dirname( dirname( TESTS_PLUGIN_DIR ) ) ) ) . '/tests/phpunit'; | ||
} | ||
|
||
// When run in wp-env context, set the test config file path. | ||
if ( ! defined( 'WP_TESTS_CONFIG_FILE_PATH' ) && false !== getenv( 'WP_PHPUNIT__TESTS_CONFIG' ) ) { | ||
define( 'WP_TESTS_CONFIG_FILE_PATH', getenv( 'WP_PHPUNIT__TESTS_CONFIG' ) ); | ||
} | ||
|
||
require_once TESTS_PLUGIN_DIR . '/vendor/yoast/wp-test-utils/src/WPIntegration/bootstrap-functions.php'; | ||
$_tests_dir = Yoast\WPTestUtils\WPIntegration\get_path_to_wp_test_dir(); | ||
require_once $_test_root . '/includes/functions.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch
Co-authored-by: Weston Ruter <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
Shall we wait to merge until Gutenberg 14.5 is released?
I don‘t see an issue with merging this already, but up to you |
The issue is the failing tests will make it hard to identify problems with other PRs being opened in the next ~2 weeks. |
You can also just temporarily skip these two tests |
Gutenberg updated in #7331. PHPUnit tests now all pass. 🎉 |
Tested it with PHP 8.1 and 8.2, Plugin functionality seems working fine with both the PHP versions. However, there are some deprecation warnings are visible in both versions. PHP8.1 PHP Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in C:\Users\win 10\Local Sites\php8amp\app\public\wp-content\plugins\amp\includes\class-amp-http.php on line 95 PHP8.2 PHP Deprecated: Return type of AMP_Validation_Callback_Wrapper::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/htdocs/current/wp-content/plugins/amp/includes/validation/class-amp-validation-callback-wrapper.php on line 425
PHP Deprecated: Creation of dynamic property AmpProject\Optimizer\Configuration\MinifyHtmlConfiguration::$minifyAmpScript is deprecated in /var/www/htdocs/current/wp-content/plugins/amp/vendor/ampproject/amp-toolbox/src/Optimizer/Configuration/BaseTransformerConfiguration.php on line 40
PHP Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /var/www/htdocs/current/wp-content/plugins/amp/includes/class-amp-http.php on line 92 |
In regards to:
This is the code in question: amp-wp/includes/class-amp-http.php Lines 78 to 98 in 68d9bb3
It looks like all that is required is: - 'status_code' => null,
+ 'status_code' => 0, |
In regards to:
I'm confused since it does have amp-wp/includes/validation/class-amp-validation-callback-wrapper.php Lines 422 to 433 in 68d9bb3
|
And finally, in regards to:
Looks like this is something that was missed in ampproject/amp-toolbox-php#533. |
Actually, it seems like this was tested without the latest $this->$key = $this->validate($key, $value); Whereas in $this->allowedKeys = $this->getAllowedKeys(); I just tried downloading the most recent development build and I see that the former is present as expected. @pavanpatil1 Could you please re-test, making sure you have the latest development build installed (as for all current QA)? |
I checked with PHP 8.2 but was unable to get any deprecation warnings other than the [06-Feb-2023 19:38:52 UTC] PHP Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /app/public/content/plugins/amp/includes/class-amp-http.php on line 92 |
QA passed ✅ Tested it with the latest development build. Functionality was working as expected before now the deprecation warnings are not visible now with both v8.1 and 8.2. solved in this PR. |
Summary
Since we use parts of the AMP plugin in the Web Stories plugin, it would be reassuring for us if it works more or less seamlessly with PHP 8.1 and 8.2.
PHP 8.2 compatibility is currently blocked by work on WordPress core itself.
Even PHP 8.1 is not seamless due to the conflict with the Requests library.
See also ampproject/amp-toolbox-php#533 (for which an update to
dev-main
is included in this PR)Checklist