Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When requesting a list of entities with an included relation where only the 'view label' operation is allowed, you'll could get an error saying that you try to use a route that does not exist if the public field name is different then the internal field name. This happens because the route name is generated using the internal field name instead of the public field name.
Proposed resolution
Make sure the EntityAccessDeniedHttpException
is created with the public field name as $relationship_field
parameter instead of the internal field name.
Remaining tasks
None? Maybe add some tests.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff-3171827-12-15.txt | 938 bytes | mohit_aghera |
#15 | 3171827-15.patch | 6.43 KB | mohit_aghera |
#12 | test-only-3171827-12.patch | 4.71 KB | mohit_aghera |
#12 | interdiff-3171827-6-12.txt | 4.71 KB | mohit_aghera |
#12 | 3171827-12.patch | 6.43 KB | mohit_aghera |
Comments
Comment #2
jmeijer CreditAttribution: jmeijer at SWIS commentedComment #3
jmeijer CreditAttribution: jmeijer at SWIS commentedComment #5
Kristen PolThanks for the issue and patch. If this is still relevant, it needs a reroll for 9.2.
Comment #6
ankithashettyRerolled the patch in #2, thanks!
Comment #7
siddhant.bhosale CreditAttribution: siddhant.bhosale as a volunteer and at QED42 commentedComment #8
siddhant.bhosale CreditAttribution: siddhant.bhosale as a volunteer and at QED42 commentedThe patch looks good and applies cleanly on 9.2.x-dev.
Looks good to be merged.
Comment #9
catchThis needs some test coverage.
Comment #10
quietone CreditAttribution: quietone as a volunteer commentedUpdating tags.
Comment #11
jibran@mohit_aghera asked for pointers on wrtitng a test for this issue in #bugsmash. Just sharing the relevant information here.
We can write a same test as
\Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::testNormalizeException()
to test this.Comment #12
mohit_aghera CreditAttribution: mohit_aghera at QED42 commentedAdding test cases and test-only patch.
Comment #15
mohit_aghera CreditAttribution: mohit_aghera at QED42 commentedTrying to fix the test cases. Updated cardinality.
Even with cardinality 1 it was passing on local somehow. Let's see how it goes.
Comment #16
Kristen PolComment #18
benjifisherPlease do not ask the testbot to try again until #3207086: [HEAD BROKEN] Consistent failure in MonthDatePluginTest is fixed.
Comment #19
alexpott#3207086: [HEAD BROKEN] Consistent failure in MonthDatePluginTest is fixed. I have not reviewed the code.
Comment #20
alexpottCommitted and pushed d84f620c57 to 9.2.x and 282d000ec5 to 9.1.x. Thanks!
The signature is
public static function assertSame($expected, $actual, string $message = ''): void
- for the message to make sense the expected value needs to come first. Fixed on commit.