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 prevent strtotime PHP deprecated #377

Merged
merged 1 commit into from
Nov 20, 2024
Merged

Fix prevent strtotime PHP deprecated #377

merged 1 commit into from
Nov 20, 2024

Conversation

crodriguezbrito
Copy link
Contributor

Proposed changes

This PR addresses the deprecated error from the strtotime() function in PHP.

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

The issue occurs when making an API call to the WooCommerce Store API (/wc/v3/products). This deprecated error is triggered if there are no products created on the site. The reason is that the API uses $product_query->get_last_modified(), which lacks error handling for cases where no products exist.

This PR will use the WooCommerce REST API endpoint (/wc/v3/products), which does not trigger the deprecated error.

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Video

Checklist

  • I have read the CONTRIBUTING doc
  • I have viewed my change in a web-browser
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@wpscholar
Copy link
Member

@aratidgr8 Do you mind testing this PR?

@aratidgr8
Copy link
Contributor

aratidgr8 commented Nov 20, 2024

@wpscholar Hey,

Myself & @amruthabs22 have tested below flows with new api call /wc/v3/products and it works fine without any errors / warnings

  1. No existing product
  2. Add product
  3. Manage products

Thanks!

CC: @crodriguezbrito

@aratidgr8 aratidgr8 merged commit 9cea042 into trunk Nov 20, 2024
5 checks passed
@aratidgr8 aratidgr8 deleted the fix/PRESS10-12 branch November 20, 2024 12:00
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