-
Notifications
You must be signed in to change notification settings - Fork 82
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 required parameter message in PHP 8.0 #231
Conversation
This fixes the following message: Deprecated: Required parameter $post follows optional parameter $actions in safe-redirect-manager/inc/classes/class-srm-post-type.php on line 98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @vinkla, thank you for the PR.
Can you please address the phpcs issue?
About the parameters, I think we should not define $actions
as an optional parameter. It's a hook so the $actions
will be always defined already. So I suggest removing the default value of $actions
instead. What do you think?
Didn't notice the error. Should be fixed now.
I'm guessing it would require a major release if we remove the default value? Maybe it could be added as a TODO for the next major release? |
That method is used for the filter only, so it's safe to change the parameter to not optional. Even it's used by themes or other site plugins, it's safe too because the second parameter is not optional, so the first one is always passed already. So I think we can change it now. cc @tlovett1 |
I've update the pull request. Even if it is only used internally it could break any other packages extending this plugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @vinkla for your contribution!
Description of the Change
This fixes the following message:
$post
can be eitherint|WP_Post|null
: https://developer.wordpress.org/reference/functions/get_post_type/Alternate Designs
N/A
Benefits
The message will now longer be visible.
Possible Drawbacks
N/A
Verification Process
I tried to update the plugin in a local WordPress application running PHP 8.0.
Checklist:
Applicable Issues
Changelog Entry
Fix required parameter following optional deprecated message in PHP 8