rollbar / rollbar-php-wordpress

Official WordPress plugin from Rollbar, Inc.
https://rollbar.com/
GNU General Public License v2.0
15 stars 20 forks source link

Fix unit tests and PHP8.1+ compatability #114

Closed aaronjorbin closed 1 year ago

aaronjorbin commented 1 year ago

Description of the change

Fix #113 and #102

This updates the unit tests to use the Yoast Pollyfill and also wp-env for testing across multiple versions of PHP.

The underlying rollbar-php is both updated and kept the same. It's updated for sites running PHP8+, but kept the same for PHP7. This introduces a bit of technical debt as the actual dependencies aren't in the composer file but instead are in the php7 and php8 folder. To help manage that, a script is included for updating those dependencies.

There are a few spots in the code that now also include PHP version specific code. When php7 support is dropped, these will need to be cleaned up.

Additionally, github actions are added in order to allow unit tests to run across multiple versions of PHP

Testing Instructions

If you want to test this change manually, you can use wp-env. clone the repo and make sure git, docker, and node are installed on your machine. Then run

npm install WP_ENV_PHP_VERSION="7.0" npm run wp-env start -- --update to start with PHP 7.0

You can login to Wordpress at http://localhost:8888/ with the username admin and the password password

If you want to test a different version of PHP, you can restart the env with a different PHP version passed in. For example, WP_ENV_PHP_VERSION="8.2" npm run wp-env start -- --update to start with PHP 8.2

Type of change

Checklists

Development

Code review

aaronjorbin commented 1 year ago

You can see the passing unit tests at https://github.com/aaronjorbin/rollbar-php-wordpress/actions/runs/5512267190

aaronjorbin commented 1 year ago

The 2,021 files changed is due to 1) Moving from having the dependencies in the main composer.json file to there being separate php8 and php7 versions 2) Removing the dependencies that are actually dev dependencies from the build.

The actual files changed that should be reviewed are and a quick summary for each file:

danielmorell commented 1 year ago

Hi @aaronjorbin, thank you for the massive amount of work you have put into this! It will take me a little bit to review this, but I think this is heading in a good direction.