Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#56219 closed defect (bug) (invalid)

Importer plugin's PHPUnit tests fail on PHP 8.1

Reported by: antonvlasenko's profile antonvlasenko Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Import Keywords: has-patch
Focuses: Cc:

Description

Steps to reproduce this bug:

  1. Make sure you are on PHP 8.1
  2. Install the importer plugin from the official repository: https://github.com/WordPress/wordpress-importer
  3. Install composer dependencies (you might have to use --ingore-platform-reqs option).
  4. Run test suite that is shipped with the importer plugin.

Expected result:
All PHPUnit tests pass.

Actual result:
PHPUnit tests fail with this error message:

PHP Fatal error:  During inheritance of ArrayAccess: Uncaught Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice ...

Change History (10)

This ticket was mentioned in PR #2977 on WordPress/wordpress-develop by anton-vlasenko.


2 years ago
#1

  • Keywords has-patch added

This PR aims to fix failing unit test that are shipped with the WordPress importer plugin.

Trac ticket: https://core.trac.wordpress.org/ticket/56219#ticket

#2 @antonvlasenko
2 years ago

  • Keywords needs-testing added

This ticket was mentioned in Slack in #core-php by antonvlasenko. View the logs.


2 years ago

#4 @antonvlasenko
2 years ago

One small remark:
I had to use PHPUnit, which is shipped with Core during testing.
PHPUnit that is included with the importer plugin doesn't support PHP 8.1.
E.g., when you are in the importer plugin's folder, you have to run the test suite like that:
php ./../../../../vendor/bin/phpunit -c phpunit.xml.dist

#5 @jrf
2 years ago

@antonvlasenko Couple of points here:

  1. The changes you are suggesting are for an external dependency. That dependency has already released a version compatible with PHP 8.1 (and 8.2 for that matter). WP just hasn't upgraded yet. See: #54504.
  2. The only reason the Importer plugin has a PHPUnit restriction is because it is needed to support older WP versions. With WP 5.9 or higher, all necessary PHPUnit versions are supported. You should NOT run with --ignore-platform-reqs. Instead you should run composer remove --dev phpunit/phpunit (this will not actually remove phpunit, but will remove the version restriction). See: https://github.com/WordPress/wordpress-importer/blob/c0e188a85c57fadde914e397bd4b0a9c104e5f17/.github/workflows/test.yml#L108-L146 for the full details and explanation.

I suggest closing this ticket as a duplicate of #54504.

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

#6 @antonvlasenko
2 years ago

  • Resolution set to invalid
  • Status changed from new to closed

@jrf
Sorry, I didn't know it's an external dependency.
Of course, let's close this ticket in favor of #54504 (especially if it can bring PHP namespaces to WordPress).

You should NOT run with --ignore-platform-reqs. Instead you should run composer remove --dev phpunit/phpunit

--ignore-platform-reqs worked for me and I didn't feel the need to modify composer.json, but thanks for the hint.

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

anton-vlasenko commented on PR #2977:


2 years ago
#7

Thank you for the feedback, @jrfnl !

I'm closing this ticket. See https://core.trac.wordpress.org/ticket/56219#comment:6 for more details.

#8 @jrf
2 years ago

--ignore-platform-reqs worked for me and I didn't feel the need to modify composer.json, but thanks for the hint.

I understand and it is a logical option to use.

The setup for integration tests for plugins can be complex as they normally support multiple WP versions and not all WP versions support the complete range of PHPUnit versions needed for the PHP versions supported.

If you're interested in understanding more about this, this blog post is probably a good starting point: Changes to the WordPress Core PHP Test Suite and the underlying ticket: #46149.

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

#9 @antonvlasenko
2 years ago

If you're interested in understanding more about this, this blog post is probably a good starting point: Changes to the WordPress Core PHP Test Suite and the underlying ticket: #46149.

Thanks, @jrf. I will read it when I have time.

#10 @desrosj
2 years ago

  • Component changed from Plugins to Import
  • Keywords needs-testing removed
  • Milestone Awaiting Review deleted
  • Version trunk deleted
Note: See TracTickets for help on using tickets.