-
Notifications
You must be signed in to change notification settings - Fork 166
add helper functions for tracking product meta change times & rate limit them (#3571) #3578
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
Conversation
This pull request was exported from Phabricator. Differential Revision: D81231381 |
6470ec6
to
34b2f95
Compare
…mit them (facebook#3578) Summary: ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Differential Revision: D81231381
This pull request was exported from Phabricator. Differential Revision: D81231381 |
34b2f95
to
731f0a3
Compare
This pull request was exported from Phabricator. Differential Revision: D81231381 |
…mit them (facebook#3578) Summary: ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe Differential Revision: D81231381
731f0a3
to
f20ff6c
Compare
This pull request was exported from Phabricator. Differential Revision: D81231381 |
…mit them (facebook#3578) Summary: Pull Request resolved: facebook#3578 Pull Request resolved: facebook#3571 ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe Differential Revision: D81231381
b0aec39
to
6aea57d
Compare
…mit them (facebook#3578) Summary: ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe Differential Revision: D81231381
This pull request was exported from Phabricator. Differential Revision: D81231381 |
…mit them (facebook#3578) Summary: Pull Request resolved: facebook#3578 Pull Request resolved: facebook#3571 ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe Differential Revision: D81231381
b3b0a68
to
e2f72a8
Compare
This pull request was exported from Phabricator. Differential Revision: D81231381 |
e2f72a8
to
93df0a8
Compare
This pull request was exported from Phabricator. Differential Revision: D81231381 |
…mit them (facebook#3578) Summary: ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe, vinkmeta Differential Revision: D81231381
93df0a8
to
5996cb4
Compare
This pull request was exported from Phabricator. Differential Revision: D81231381 |
…mit them (facebook#3578) Summary: Pull Request resolved: facebook#3578 Pull Request resolved: facebook#3571 ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe, vinkmeta Differential Revision: D81231381
5996cb4
to
6440314
Compare
…mit them (facebook#3578) Summary: ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe, vinkmeta Differential Revision: D81231381
…mit them (facebook#3578) Summary: ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe, vinkmeta Differential Revision: D81231381
6440314
to
3ac061c
Compare
This pull request was exported from Phabricator. Differential Revision: D81231381 |
* add helper functions for tracking product meta change times & rate limit them (facebook#3578) Summary: ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.7 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe, vinkmeta Differential Revision: D81231381 * main decision function based on meta key & product validation (facebook#3575) Summary: Here is a summary of the diff in markdown format: **Main Decision Function based on Meta Key & Product Validation** ================================================================= **Overview** ----------- This diff introduces a new function `is_meta_key_sync_relevant` in the `facebook-commerce.php` file. The function checks if a given meta key affects Facebook sync and should trigger a last change time update. ** Changes ** ------------ * Added a new function `is_meta_key_sync_relevant` to check if a meta key is relevant to Facebook sync. * The function skips the plugin's own meta keys to prevent infinite loops. **Function Details** ------------------- ### `is_meta_key_sync_relevant` * **Purpose:** Checks if a meta key affects Facebook sync and should trigger a last change time update. * **Parameters:** `$meta_key` (string) - the meta key to check. * **Return Value:** `true` if the meta key is relevant to Facebook sync, `false` otherwise. * **Since:** 3.5.7 **Example Use Case** ------------------- ```php $meta_key = '_last_change_time'; if ( $this->is_meta_key_sync_relevant( $meta_key ) ) { // Trigger last change time update } ``` Reviewed By: devbodaghe Differential Revision: D81231384 * add product meta change_time handler (facebook#3576) Summary: Changes Made - 1. Added is_updating_last_change_time flag to be protect from infinite loop of update_post_meta hook 2. Added hook for updated_post_meta 3. Added update_last_change_time - It validates & performs the update on _last_change_time 4. Added perform_last_change_time_update to actually perform the update Reviewed By: devbodaghe Differential Revision: D81231383 * integrate last change time into external_update_time calculation (facebook#3577) Summary: Comparing _last_modified_time field in wp_post & custom _last_change_time in wp_postmeta & choosing the latest timestamp for the most accurate depiction of latest change on a post Reviewed By: vinkmeta Differential Revision: D81231380
This pull request has been merged in a424319. |
…mit them (#3578) Summary: Pull Request resolved: #3578 Pull Request resolved: #3571 ## Changes to Facebook for WooCommerce Plugin ### Summary This diff introduces helper functions for tracking product meta change times and rate limiting updates. Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID. Why is this change needed? In a single request, **update_post_meta could be called N+ times for a single product**. As, we intend to update timestamp value based on writes in wp_postmeta table - this could lead to thousands of writes for simple product changes. Rate Limiting function **allows only 1 write to _last_change_time per product within a request even for N+ writes.** This allows us to keep a fresh _last_change_time value & also avoiding too many writes. ### Key Features * Checks for rate limiting based on a cached time for each product ID * Uses the WordPress cache to store the last change time for each product * Returns a boolean value indicating whether the update is rate limited or not ### Version History * Since 3.5.8 ### Example Use Case ```php $product_id = 123; $is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id); if (!$is_rate_limited) { // Proceed with updating the product meta change time } else { // Update is rate limited, skip or reschedule the update } ``` Reviewed By: devbodaghe, vinkmeta Differential Revision: D81231381 fbshipit-source-id: c9fb35202b32c228ff76b78c695c5e07bc4e66ac
Summary:
Changes to Facebook for WooCommerce Plugin
Summary
This diff introduces helper functions for tracking product meta change times and rate limiting updates.
Specifically, it adds a new function
is_last_change_time_update_rate_limited
to thefacebook-commerce.php
file. This function checks if the last change time update is rate limited for a given product ID.Key Features
Version History
Example Use Case
Differential Revision: D81231381