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

BUG: passing null value to prepare_date_items() leads to deprecation warning in strtotime() #3971

Open
1 task done
barryceelen opened this issue Aug 27, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@barryceelen
Copy link
Member

barryceelen commented Aug 27, 2024

Describe the bug

The $post_date variable passed to Post->prepare_date_items() in Post->prepare_document() can be null. Post->prepare_date_items() uses that value in a strtotime() call. Passing null to strtotime() results in a PHP deprecation warning.

...Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in...

Steps to Reproduce

Indexing a post with $post->post_date set to 0000-00-00 00:00:00 or an otherwise invalid $post->post_date value results in the $post_date variable being set to null:

https://github.com/10up/ElasticPress/blob/develop/includes/classes/Indexable/Post/Post.php#L463

Code of Conduct

  • I agree to follow this project's Code of Conduct
@barryceelen barryceelen added the bug Something isn't working label Aug 27, 2024
@felipeelia felipeelia added this to the 5.2.0 milestone Aug 30, 2024
@felipeelia
Copy link
Member

Thanks @barryceelen! Any chance you can open a PR with the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants