Feature/add reset connection option#3843
Conversation
- 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.
|
Hi @ericmulder! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Any news on this PR? |
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
Checklist
Changelog entry
Add reset connection and reset plugin options to Woocommerce > status > tools
Test Plan
Screenshots