Skip to content

Commit 7b5a25c

Browse files
sol-loupmeta-codesync[bot]
authored andcommitted
Fix: Prevent integer overflow in Facebook product IDs (#3688)
Summary: ## Description This PR fixes an integer overflow issue where large Facebook product IDs (e.g., `8643851039008202`) were being stored as numeric types and could overflow to scientific notation (`6.19203E+15`) on 32-bit systems or in certain PHP configurations. This caused sync and tracking issues for affected stores. The fix adds explicit `(string)` type casting when storing Facebook product IDs via `update_post_meta()`, following the same pattern already used in the `get_existing_fbid()` method (lines 1998-2010). **Fixes #2825 ### Type of change - Fix (non-breaking change which fixes an issue) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Fix: Prevent integer overflow in Facebook product IDs by explicitly casting to string Pull Request resolved: #3688 Test Plan: ### Manual Testing 1. Create a test scenario that simulates receiving a large Facebook product ID (e.g., `8643851039008202`) 2. Verify that the ID is stored correctly in post meta without conversion to scientific notation 3. Confirm that product sync continues to work correctly ### Code Review - Review the two locations where the fix was applied (lines 1404 and 1474 in `facebook-commerce.php`) - Confirm the pattern matches the existing implementation in `get_existing_fbid()` (lines 1998-2010) - Verify that `(string)` casting is safe and non-breaking for all ID formats ### Compatibility - The change is backward compatible - string casting works for all numeric ID formats - No changes to external APIs or data structures - No database migrations required ## Screenshots Not applicable - this is a data type handling fix with no UI changes. ### Before Facebook product IDs could overflow to scientific notation (e.g., `6.19203E+15`) when stored in post meta. ### After Facebook product IDs are explicitly cast to strings, preventing overflow regardless of system architecture or PHP configuration. **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/11540474168531687 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/4785074925462798 Reviewed By: ajello-meta, devbodaghe, strygo Differential Revision: D85895423 Pulled By: sol-loup fbshipit-source-id: 8d56dcb32d6ecdc55ea8ec38b35af78f91dd5a09
1 parent 6800e6d commit 7b5a25c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

facebook-commerce.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ public function create_product_group( WC_Facebook_Product $woo_product, string $
14011401
update_post_meta(
14021402
$woo_product->get_id(),
14031403
self::FB_PRODUCT_GROUP_ID,
1404-
$fb_product_group_id
1404+
(string) $fb_product_group_id
14051405
);
14061406

14071407
return $fb_product_group_id;
@@ -1471,7 +1471,7 @@ public function create_product_item( $woo_product, $retailer_id, $product_group_
14711471
update_post_meta(
14721472
$woo_product->get_id(),
14731473
self::FB_PRODUCT_ITEM_ID,
1474-
$fb_product_item_id
1474+
(string) $fb_product_item_id
14751475
);
14761476

14771477
$this->display_success_message(

0 commit comments

Comments
 (0)