Skip to content
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 compatibility fixes #3357

Merged
merged 46 commits into from
Aug 19, 2024

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Aug 12, 2024

Fixes #2411
Base PR: #3355

Changes proposed in this Pull Request:

This PR fixes issues when running the application on PHP 8.1. Basically, a new CI test node was added with this specific version, and deprecation issues were fixed. Especially calls to get_option(), as it can return false and it is not possible to automatically convert it to empty arrays anymore.

To better solve the issue above, I have centralized the retrieval, update, and deletion of the main Stripe settings option on the WC_Stripe_Helper class, and replaced all calls to those functions with the new static methods.

Initially, this PR should also add support for running tests with PHPUnit 10.5, but I dropped it since most of the base classes required to run our wordpress-tests-lib were removed on the major version. So, in order to progress with it we should also work on wordpress-tests-lib first. There's a long conversation about this issue (3 years) here.

Testing instructions

Code review should be enough. Check if the tests are still passing.


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@wjrosa wjrosa self-assigned this Aug 12, 2024
@wjrosa wjrosa changed the title Fix/compatibility with php 8 1 and phpunit 10 5 PHP 8.1 and PHPUnit 10.5 compatibility fixes Aug 12, 2024
@wjrosa wjrosa changed the title PHP 8.1 and PHPUnit 10.5 compatibility fixes PHP 8.1 compatibility fixes Aug 13, 2024
@wjrosa wjrosa changed the base branch from develop to fix/fix-connection-array-merge-error August 13, 2024 17:22
@wjrosa wjrosa marked this pull request as ready for review August 13, 2024 19:03
@wjrosa wjrosa requested review from a team and diegocurbelo and removed request for a team August 13, 2024 19:15
Base automatically changed from fix/fix-connection-array-merge-error to develop August 14, 2024 14:15
Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on the newer PHP fixes @wjrosa!

The code changes look good, and all tests pass*. I left a few comments with questions.

  • The E2E checks fail in the PR, but they pass using the same docker env locally.
    We already have an issue to fix the flakiness.

.github/workflows/e2e-tests.yml Outdated Show resolved Hide resolved
woocommerce-gateway-stripe.php Show resolved Hide resolved
includes/class-wc-stripe-helper.php Outdated Show resolved Hide resolved
tests/e2e/tests/orders/full-refund.spec.js Outdated Show resolved Hide resolved
includes/connect/class-wc-stripe-connect.php Show resolved Hide resolved
@@ -158,11 +158,17 @@ function ( $id ) {
$ids_to_migrate = $this->get_subs_ids_to_migrate();

$this->logger_mock
->expects( $this->at( 1 ) )
->expects( $this->exactly( 2 ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to update these tests? The new update_main_stripe_settings does not log anything 🤷🏼
Do we know where is the additional log entry coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at() was deprecated in PHPUnit 9. So, it threw many warnings when running the tests. I decided to refactor them here already. It is not a blocker, as we could wait for PHPUnit 10 (which removed this). I can also revert this if that is preferable.

package.json Outdated Show resolved Hide resolved
@wjrosa wjrosa requested a review from diegocurbelo August 16, 2024 14:17
Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes @wjrosa 🚢

@wjrosa wjrosa merged commit f89dee1 into develop Aug 19, 2024
34 of 35 checks passed
@wjrosa wjrosa deleted the fix/compatibility-with-php-8-1-and-phpunit-10-5 branch August 19, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compatibility with PHP 8.1
2 participants