-
Notifications
You must be signed in to change notification settings - Fork 168
pb fix option 1 #3609
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
base: main
Are you sure you want to change the base?
pb fix option 1 #3609
Conversation
📦 Latest Plugin BuildBuilt at: 2025-09-26T02:19:22.793Z Download: Click here to download the plugin To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reviewing the param_builder_set_cookies
and init_param_builder
functions, I noticed that param_builder_set_cookies
depends on the param_builder being initialized. Currently, with this fix, param_builder_set_cookies
runs on the init hook at priority 1, while init_param_builder
runs at priority 5. Since the cookie function relies on the param_builder
, we need to run init_param_builder
first, so increasing its priority to at least 6 ensures proper initialization before setting cookies. This priority should also prevent the “headers already sent” warning.
Yes, you are right. I think I might found the issue. get_integration did not have a priority with it and it runs other add actions that triggers interaction with browser. The previous version eliminate many cases because we try to force param_builder_set_cookies run early but there's no guarantee. Lmk if there's other concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now we have the order:
- init_param_builder
- param_builder_set_cookies
- get_integration
Given that the integration class mainly handles feed-related actions (syncing, updating, etc.), this order looks fine, and after testing I don't see any warnings that were reported previously.
One possible improvement: we could add lazy initialization inside get_param_builder()
, similar to how get_integration()
works. That way, we ensure the param builder is always available when requested, without relying strictly on hook priority.
public function get_param_builder() {
if ( null === $this->param_builder ) {
$this->init_param_builder();
}
return $this->param_builder;
}
That's a good idea, now I can get rid of this https://github.com/facebook/facebook-for-woocommerce/blob/main/facebook-commerce-events-tracker.php#L194-L196. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @chc421,
I tested the flow again and can confirm both _fbp
(always set) and _fbc
(when fbclid is present) cookies are working correctly, and no warnings are triggered.
Thank you for testing. Could you help me to stamp? |
Description
Re-order server parambuilder library load order
Type of change
Please delete options that are not relevant
Checklist
Changelog entry
One liner entry to be surfaced in changelog.txt
Test Plan
Manual test
Test case 1 (New visitor):
Test case 2 (Existing user):
Screenshots
Before
[17-Sep-2025 15:15:12 UTC] PHP Warning: Cannot modify header information - headers already sent in /Users/chenghaochen/Local Sites/local-color-crush/app/public/wp-content/plugins/facebook-for-woocommerce/facebook-commerce-events-tracker.php on line 203
After