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

Use date_Create that does not throw exception or warning #2340

Merged
merged 1 commit into from
Sep 8, 2021

Conversation

pschoffer
Copy link
Contributor

@pschoffer pschoffer commented Sep 6, 2021

Description of the Change

This is inspired by Automattic#113

It seems that new \DateTime( $meta_value, \wp_timezone() ); throws not only exception but also a E_WARNING in certain cases.

There is the date_create alternative, that according to manual is an alias. While testing it though, I found that, it returns false on failure and does NOT throw an exception or warning (as far as I can see).

There are already unittests covering this function that are passing and also testing on the local dev-environment results in good results.

Alternate Designs

Benefits

Possible Drawbacks

Verification Process

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

Changed - Meta parsing tweak to avoid E_WARNINGs

@sjinks
Copy link
Contributor

sjinks commented Sep 7, 2021

date_create() indeed does not spit a warning:

Warnings are spit only when php_date_initialize() is invoked from the constructor (the ctor argument is 1); for date_create ctor is 0.

@pschoffer
Copy link
Contributor Author

Thanks for that @sjinks . One day I will bother you to teach me your super-power of tracking that down (I tried but failed)

@felipeelia felipeelia merged commit e4194a6 into 10up:develop Sep 8, 2021
@felipeelia felipeelia added this to the 3.6.3 milestone Sep 27, 2021
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