Fix Security "this" variable on ExtendType fields#801
Merged
oojacoboo merged 1 commit intothecodingmachine:masterfrom Apr 25, 2026
Merged
Fix Security "this" variable on ExtendType fields#801oojacoboo merged 1 commit intothecodingmachine:masterfrom
oojacoboo merged 1 commit intothecodingmachine:masterfrom
Conversation
Fixes thecodingmachine#653 Related to thecodingmachine#792 When using #[Security] on a field declared in an #[ExtendType], the 'this' variable was incorrectly set to the resolver instance instead of the source object. This breaks authorization logic relying on the domain object. Fix: preserve $source when injectSource=true. Adds test coverage to ensure correct behavior.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #801 +/- ##
============================================
- Coverage 95.72% 94.84% -0.89%
- Complexity 1773 1893 +120
============================================
Files 154 176 +22
Lines 4586 4982 +396
============================================
+ Hits 4390 4725 +335
- Misses 196 257 +61 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
oojacoboo
approved these changes
Apr 25, 2026
Collaborator
|
Thanks @charly-ffss! |
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.
Fixes #653
Related to #792
Problem
When using
#[Security]on a field declared in an#[ExtendType], thethisvariable incorrectly points to the resolver instance instead of the source object.
This breaks authorization logic relying on the domain object (e.g. voters).
Fix
Preserve
$sourcewheninjectSource=trueinstead of always using$originalResolver->executionSource($source).Test coverage
Extends existing end-to-end test to assert that:
thisis the source objectResult
#[Security]on#[ExtendType]