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

Prevent errors when wp_insert_post filters send an unexpected type #131

Merged
merged 3 commits into from
May 11, 2023

Conversation

goldenapples
Copy link
Contributor

@goldenapples goldenapples commented May 9, 2023

The third argument passed along with the wp_insert_post_data hook can be a number of different types.

This avoids PHP errors trying to access a WP_Post object as an array by coercing that value to an array before trying to access it.

The third argument passed along with the `wp_insert_post_data` hook can
be a number of different types. This adds a type check to avoid PHP
error trying to access a WP_Post object as an array.
This function also fatals if a WP_Post is passed into it. (It'd be nice
to specify union types, but pre-PHP 8 that wasn't supported.)
Copy link
Member

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

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

Looks good, just the @param tag for the parameter needs to be updated too

@goldenapples
Copy link
Contributor Author

Thanks, I've updated the @param annotation. Care to re-review? 🙏

@goldenapples goldenapples merged commit 70e82f5 into develop May 11, 2023
@goldenapples goldenapples deleted the fix-param-type-array branch May 11, 2023 14:21
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.

2 participants