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

Fix fatal errors on PHP 7.4 #177

Merged
merged 1 commit into from
Mar 30, 2023
Merged

Fix fatal errors on PHP 7.4 #177

merged 1 commit into from
Mar 30, 2023

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Mar 2, 2023

Description of the Change

In #169, return types were added to a few methods to address some deprecation notices showing up if you were using PHP 8.1. We also bumped our minimum PHP version to 7.4 in #170. The problem here is we used the mixed return type in a few places and full support for that wasn't added until PHP 8.

This means anyone running the latest version of this plugin (v4.3.4) and still running PHP 7.4, will end up with fatal errors that cause the plugin to not function.

This PR addresses this by removing the mixed return type and adding the #[\ReturnTypeWillChange] attribute to suppress the deprecation notices for those running PHP 8.1. This should solve both the original issue as well as the newly introduced issue on PHP 7.4.

One thing to note here is once we do bump our minimum PHP version to 8.0, we'll want to remove the use of these attributes.

How to test the Change

In an environment running PHP 7.4, go and configure the plugin. Prior to the changes here, you'll end up with a fatal error when the container settings are rendered. After this change, things should load as expected.

In an environment running PHP 8.0+, go and configure the plugin. Everything should work as expected and no deprecation warnings should be logged.

Changelog Entry

Fixed - Ensure things work on PHP 7.4

Credits

Props @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

…new attribute that will suppress the deprecation notice on PHP 8.1
@dkotter dkotter self-assigned this Mar 2, 2023
@dkotter dkotter requested review from a team and rickalee as code owners March 2, 2023 22:13
@dkotter dkotter requested review from Sidsector9 and removed request for a team March 2, 2023 22:13
@dkotter
Copy link
Collaborator Author

dkotter commented Mar 2, 2023

Note that #178 is an alternative to this PR. We don't want to merge both of those in, we just need to decide which of these two is the right path forward.

Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@dkotter IMO we can go ahead with this instead of PR #178 as WordPress itself supports PHP min 7.4.

@dkotter dkotter added this to the 4.4.0 milestone Mar 30, 2023
@dkotter dkotter merged commit c510c3f into develop Mar 30, 2023
@dkotter dkotter deleted the fix/php-7-4-fatal branch March 30, 2023 17:38
@mrmt
Copy link

mrmt commented Jun 5, 2023

Hi,
We were quite distressed by this problem, and this PR solved the issue.
I hope you will release this fix for other people suffering from the same problem. Thanks!!

@dkotter dkotter modified the milestones: 4.4.0, 4.3.5 Jul 3, 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.

3 participants