Repository navigation
fix(network): removing a store through addStores keeps its other networks - #139
Merged
Merged
Conversation
…orks
addStores() deleted the requested stores with
NetworkStore::where('store_uuid', $storeId)->delete(), with no network
condition, so removing a store from one network removed it from every
network it belonged to. The delete is now scoped to this network, as
removeStores() already is.
roncodes
added a commit
that referenced
this pull request
Oct 13, 2026
Conflict in NetworkController::addStores: #139 scoped the `remove` deletes to the network the same way; kept its version and comment. deleteCategory keeps the scoped network uuid plus #140's cache invalidation. Tests from #139/#140 that call network actions now give the network a company and set the session company; ApiCacheInvalidationTest calls the public reinstateStores action instead of setMembershipStatus by reflection (it now takes the resolved Network).
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.
Summary
NetworkController::addStores()(POST storefront/int/v1/networks/{id}/add-stores) deleted each store listed inremovewithNetworkStore::where('store_uuid', $storeId)->delete(). There was nonetwork_uuidcondition, so removing a store from one network also removed it from every other network it belonged to, including networks of other companies the store had joined by invitation. The delete is now scoped to the network in the URL, asremoveStores()already does.Related Issue
None. Found in the same audit as the API list cache scoping fix, fleetbase/core-api#300.
Type of Change
Implementation Notes
The change is one line:
NetworkStore::where(['network_uuid' => $network->uuid, 'store_uuid' => $storeId])->delete().The new test
network controller add stores removes a store from this network onlyinSmallControllerContractsTest.phpputs one store in two networks, removes it throughaddStoreson the first network, and asserts that only the first network's membership is soft-deleted. Against the previous code it fails: the other network's row was deleted too (Failed asserting that '2026-10-12 14:17:39' is null).Validation
Documentation Impact
API Reference Impact
API reference notes: this is an internal console endpoint, and its request and response are unchanged. The endpoint now does what its callers expect.
Documentation Notes
None.
Risk
Low. The only behavior that changes is that other networks keep their memberships. No migration is needed. Memberships already removed from other networks by this bug are not restored; they would need to be re-added.
Screenshots / Recordings
None (no UI change).