Skip to content

Feature/add reset connection option#3843

Open
ericmulder wants to merge 3 commits into
facebook:mainfrom
labelvier:feature/add-reset-connection-option
Open

Feature/add reset connection option#3843
ericmulder wants to merge 3 commits into
facebook:mainfrom
labelvier:feature/add-reset-connection-option

Conversation

@ericmulder

Copy link
Copy Markdown

Description

In the Woocommerce status menu we added 2 option. 1) Reset the Facebook connection, and 2) To totally reset the Facebook plugin. We built this because sometimes our clients need to re-add the connection or totally reset the Facebook connection.
We saw there was already a reset option available, but hidden via a debug flag (which confused the users which don't have debug enabled). For now I left that option available, but it might be wise to merge these two.

Type of change

Please delete options that are not relevant

  • Add (non-breaking change which adds functionality)

Checklist

  • I have commented my code, particularly in hard-to-understand areas, if any.
  • I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
  • I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
  • I followed general Pull Request best practices. Meta employees to follow this wiki.
  • I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
  • 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). Meta employees to follow this wiki.

Changelog entry

Add reset connection and reset plugin options to Woocommerce > status > tools

Test Plan

  • Connect the plugin to a Facebook account
  • Set some options in the plugin
  • Use the reset connection option in Woocommerce -> status -> tools
  • Check if you can re-connect again, and check if options are still available
  • Use the reset plugin option
  • Connect again and check if you start with a clean sheet

Screenshots

Screenshot 2026-02-02 at 12 22 41
- Add two new reset tools to WooCommerce > Status > Tools:
  1. Reset connection data: Clears tokens/IDs while preserving settings
  2. Reset all settings: Complete reset to fresh installation state

- Implement reset_connection_only() method in Connection handler
  - Removes connection tokens, business IDs, page/pixel IDs
  - Preserves product sync settings, excluded categories, debug mode
  - Fires wc_facebook_connection_only_reset action hook

- Implement reset_connection() method in Connection handler
  - Removes ALL Facebook-related options from database
  - Returns plugin to fresh installation state
  - Fires wc_facebook_connection_reset action hook

- Update DebugTools to register both reset options
  - Tools are always visible (no debug mode required)
  - Clear descriptions explain what each tool does
  - Marked legacy reset tool for clarity

This provides users with flexible troubleshooting options for
connection issues while following WooCommerce conventions.
- Created ConnectionResetTest with 15 test cases covering reset_connection() and reset_connection_only()
- Tests verify that connection options are deleted while settings are preserved appropriately
- Tests verify action hooks are fired correctly
- Refactored tests to use constants from MetaExtension and Integration classes instead of hardcoded strings
- This makes tests more maintainable and refactoring-proof
- Updated disconnect() to use delete_option() instead of update_option($option, '')
- Updated reset_connection_only() to consistently use delete_option()
- Removed redundant code that was setting options to empty strings before deleting them
- Added pre_delete_option filter support to AbstractWPUnitTestWithOptionIsolationAndSafeFiltering
- Changed ConnectionResetTest to extend AbstractWPUnitTestWithSafeFiltering instead of
  AbstractWPUnitTestWithOptionIsolationAndSafeFiltering to allow actual database operations
- Updated DebugToolsTest expectations to reflect new always-visible reset tools
- All 30 tests now pass (15 ConnectionResetTest + 15 DebugToolsTest)

The key fix was recognizing that option isolation was preventing delete_option()
from working properly. Since we're testing database deletion operations, we need
the options to actually be in the database, not in a mocked array.
@meta-cla

meta-cla Bot commented Feb 2, 2026

Copy link
Copy Markdown

Hi @ericmulder!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Feb 2, 2026
@meta-cla

meta-cla Bot commented Feb 2, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@ericmulder

Copy link
Copy Markdown
Author

Any news on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant