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 required parameter message in PHP 8.0 #231

Merged
merged 3 commits into from
Mar 15, 2021
Merged

Fix required parameter message in PHP 8.0 #231

merged 3 commits into from
Mar 15, 2021

Conversation

vinkla
Copy link
Contributor

@vinkla vinkla commented Mar 5, 2021

Description of the Change

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

$post can be either int|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:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

Changelog Entry

Fix required parameter following optional deprecated message in PHP 8

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
@jeffpaul jeffpaul added this to the 1.10.1 milestone Mar 5, 2021
@jeffpaul jeffpaul requested a review from dinhtungdu March 5, 2021 17:22
@jeffpaul jeffpaul added the type:bug Something isn’t working. label Mar 5, 2021
Copy link
Collaborator

@dinhtungdu dinhtungdu left a 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?

@vinkla
Copy link
Contributor Author

vinkla commented Mar 14, 2021

Can you please address the phpcs issue?

Didn't notice the error. Should be fixed now.

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?

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?

@dinhtungdu
Copy link
Collaborator

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

@vinkla
Copy link
Contributor Author

vinkla commented Mar 15, 2021

I've update the pull request. Even if it is only used internally it could break any other packages extending this plugin.

Copy link
Collaborator

@dinhtungdu dinhtungdu left a 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!

@jeffpaul jeffpaul merged commit 10ef158 into 10up:develop Mar 15, 2021
@vinkla vinkla deleted the patch-1 branch March 15, 2021 18:29
@jeffpaul jeffpaul linked an issue Oct 29, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn’t working.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure compatibility with PHP 8
3 participants