Skip to content

Conversation

rithikb24
Copy link
Contributor

Differential Revision: D81231380

@meta-cla meta-cla bot added the CLA Signed label Aug 29, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81231380

rithikb24 added a commit to rithikb24/facebook-for-woocommerce that referenced this pull request Aug 29, 2025
…ebook#3577)

Summary:



Rollback Plan:

Differential Revision: D81231380
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81231380

rithikb24 added a commit to rithikb24/facebook-for-woocommerce that referenced this pull request Sep 1, 2025
…ebook#3577)

Summary:



Rollback Plan:

Differential Revision: D81231380
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81231380

@rithikb24 rithikb24 added the changelog: add A new feature, function, or functionality was added. label Sep 1, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81231380

…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
…ok#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
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
…ebook#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
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81231380

rithikb24 added a commit to rithikb24/facebook-for-woocommerce that referenced this pull request Sep 4, 2025
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. CLA Signed fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants