Release v1.6.61 - #252
Merged
Merged
Release v1.6.61#252
Conversation
`User::$role`, `$roles`, `$policies` and `$permissions` each execute a fresh query on every read, because they call the relation as a query builder (`$this->companyUser->roles()->first()`) rather than reading the loaded relation. Eager-loading `companyUser.roles` therefore does nothing: the data is loaded and the accessor queries anyway. `Http\Resources\User::toArray()` compounds it by evaluating `$this->role` four times per row (twice for `role`, twice for `role_name`). Measured on a real page with `DB::listen`, 5 users: today 12 queries/row resource reads `role` once 8 queries/row + eager-load `companyUser` 7 queries/row + deep eager-load (roles/policies/permissions) 7 queries/row (no change) accessors honour the loaded relation + eager-load 0 queries/row Each accessor now prefers the loaded relation and falls back to the query when it is absent, so behaviour is unchanged for callers that do not eager-load. The `instanceof Model` guard keeps duck-typed pivots working -- the suite's own UserModelAuthorizationPivotFake is one. No response shape changes, no memoisation, and nothing new appears in the model's array output. Adds a test whose pivot throws from roles()/policies()/permissions(), so the suite fails loudly if an accessor ever queries past a loaded relation again.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #252 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 6734 6750 +16
===========================================
Files 397 398 +1
Lines 22470 22502 +32
===========================================
+ Hits 22470 22502 +32
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ors-honour-eager-loading perf(user): let authorization accessors honour eager-loaded relations (12 → 0 queries/row)
roncodes
marked this pull request as ready for review
September 9, 2026 04:51
This was referenced Sep 9, 2026
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.
Prepare Core API v1.6.61 for release.
The branch currently enables PHP CI and Postman checks for
release/v*branches. PR #251 targets this branch and will add batched user authorization loading that matches each user's company membership, with database-backed regression coverage.This release PR is a draft while #251 remains open. Before merging:
release/v1.6.61and verify its checks.composer.jsonto version1.6.61and replaceRELEASE.mdwith current-release notes.The current diff contains only the two workflow branch-filter updates. The authorization patch is not included yet. Its local test suite, style check, and date-drift check passed; its GitHub Actions runs still require fork-workflow approval.