Skip to content

fix(network): removing a store through addStores keeps its other networks - #139

Merged
roncodes merged 1 commit into
release/v0.4.25from
fix/network-remove-store-scope
Oct 13, 2026
Merged

roncodes merged 1 commit into
release/v0.4.25from
fix/network-remove-store-scope

Conversation

@roncodes

Copy link
Copy Markdown
Member

Summary

NetworkController::addStores() (POST storefront/int/v1/networks/{id}/add-stores) deleted each store listed in remove with NetworkStore::where('store_uuid', $storeId)->delete(). There was no network_uuid condition, 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, as removeStores() already does.

Related Issue

None. Found in the same audit as the API list cache scoping fix, fleetbase/core-api#300.

Type of Change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Test
  • Chore

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 only in SmallControllerContractsTest.php puts one store in two networks, removes it through addStores on 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

  • Tests
  • Lint
  • Build: PHP-only change
  • Manual validation
SmallControllerContractsTest.php: 23 tests, 106 assertions, 0 failures, 0 errors (new test fails before the fix)
php-cs-fixer --dry-run on both changed files: 0 of 1 files to fix (each)
Full server suite (scripts/pest-runner.php server/tests): 664 tests, 0 failures, 22 errors.
  All 22 are `Class "Fleetbase\Support\SocketCluster\..." not found` in CheckoutBoundaryContractsTest,
  StorefrontSocketTest and StorefrontServiceProviderTest: my local server_vendor core-api predates
  socket auth. They are unrelated to this change; CI installs current core-api.

Documentation Impact

  • No documentation changes needed

API Reference Impact

  • No API reference changes needed

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).

…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 roncodes added the type:bug Bug fix label Oct 12, 2026
@roncodes
roncodes merged commit fbe8114 into release/v0.4.25 Oct 13, 2026
@roncodes
roncodes deleted the fix/network-remove-store-scope branch October 13, 2026 06:20
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant