Skip to content

Conversation

aaronjorbin
Copy link
Collaborator

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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Checklists

Development

  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

- Switch from standard PHPUnit to yoast polyfill.
- Setup sniff dependencies
Version 2 requires PHP7.4
`void` can't be used as a return type in PHP 7.0. The Yoast runner
has helpers for this, so switching to those.
See: https://github.com/Yoast/PHPUnit-Polyfills#testcases
v4 of the library introduced a few breaking changes.
1) GenerateErrorWrappr requries line to be an int
2) Rollbar\RollbarLogger:: log is now a wrapper around `report` that
doesn't return the value that log used to return
Focus on the current stable WordPress, but still include upcoming WP
Add script for updating dependecies
@aaronjorbin
Copy link
Collaborator Author

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

@aaronjorbin
Copy link
Collaborator Author

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 danielmorell self-requested a review July 11, 2023 10:11
@danielmorell danielmorell self-assigned this Jul 11, 2023
@danielmorell
Copy link
Collaborator

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.

@danielmorell danielmorell added this to the v3.0.0 milestone Jul 31, 2023
Copy link
Collaborator

@danielmorell danielmorell left a comment

Choose a reason for hiding this comment

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

@aaronjorbin Thank you for the work you have put into this. It looks really good! Sorry it took me a bit to go through.

@danielmorell danielmorell merged commit d552031 into rollbar:master Jul 31, 2023
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.

Please fix compatibility with PHP 8.1
2 participants