Make Disconnect safe on a copied site (1.1.0) - #14
Open
DAAAAAAAAAAAAAAAAN wants to merge 1 commit into
Open
DAAAAAAAAAAAAAAAAN wants to merge 1 commit into
DAAAAAAAAAAAAAAAAN wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A partner's site was database-copied to a second domain. The copy carried
printeers_connected,printeers_store_urland the WooCommerce API key of theoriginal. Clicking Disconnect on the copy posted the original's URL and
consumer secret to
/woocommerce/disconnect, and Printeers uninstalled theoriginal store (verified in prod on 2026-09-14/15).
What
site_url. The disconnect body now contains exactlystore_url,consumer_secretandsite_url(home_url()at click time).The callback API compares
site_urlwith the install's store URL and refuseswith 409 when they differ. Unknown keys are rejected server-side, so no other
keys are sent.
to the error notice, so a 409 reads as
this connection belongs to <store>, not to <site>; it was left intact.the stored store URL with
home_url(), both normalized the way the servercanonicalizes store URLs (host lower-cased,
:443dropped, trailing slashtrimmed, scheme compared as https). On a mismatch it shows a warning state
with both URLs and one button, Remove connection from this site, which
deletes the local API key row and the plugin options and never contacts
Printeers. The regular Disconnect form is not rendered in that state. After
removal the page is "Not connected" and Connect works as a fresh connect for
the copy's own URL.
connect the new domain as its own store, retire the old one in the Dashboard.
The notice says so.
Connect::disconnect()is unchanged apart from the body; the guard lives inthe UI path so a stray caller still gets the server-side 409.
pauses the store and that a copied site cannot disconnect the original.
1.1.0 changelog, stable tag and version bump.
uninstall.phpis untouched: deleting the plugin already removes local statewithout notifying Printeers, which is right for both real and copied sites.
Server side
Pairs with ipp branch
agent/woocommerce-plugin-disconnect-sideline(
1c4d9f029), which adds thesite_urlcheck and turns a plugin disconnectinto a pause instead of an uninstall. Ordering does not matter: the server
accepts bodies without
site_url, so 1.0.0 plugins keep working, and thisplugin against the current server just gets its extra key rejected with a 400
that is shown in the notice. Merge the server first for a clean rollout.
Testing
Done:
php -lon every file under PHP 7.4 and 8.3.normalize_url()checked standalone: case,:443, trailing slash,http/https, query and fragment, non-default port, IPv6, empty input.
(Disconnect shown), copied site (Disconnect hidden, remove form with its own
nonce), after removal (Not connected + success notice), failed disconnect
(409 reason shown).
Not done, needs the ipp branch deployed to the local cluster:
store sidelined, Dashboard banner appears and clears on reconnect.wp option update printeers_store_url https://other.example):mismatch state shown, remove clears the four options and the
wp_woocommerce_api_keysrow, no HTTP request in callback-api logs.curlwith a foreignsite_url: 409, install unchanged.🤖 Generated with Claude Code