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.
@dawehner thinks this might be a duplicate of an existing issue, but I wanted to make sure to document it until we confirm.
Steps to reproduce
- Install 8.x Standard.
- Create a new view of users with a page display and path
users-by-role
. - Add a contextual filter for the user role.
- Go to
users-by-role/administrator
. You get the fatal:
Fatal error: Call to a member function label() on a non-object in /Applications/MAMP/htdocs/d8git/core/modules/user/lib/Drupal/user/Plugin/views/argument/RolesRid.php on line 23
Comment | File | Size | Author |
---|---|---|---|
#20 | views-role-contextual-filter-1995868-19-FAIL.patch | 6.23 KB | xjm |
#20 | views-role-contextual-filter-1995868-19.patch | 8.64 KB | xjm |
#19 | views-role-contextual-filter-1995868-19.patch | 8.64 KB | xjm |
#19 | interdiff-1995868.txt | 2.87 KB | xjm |
#16 | drupal-1995868-16.patch | 8.58 KB | dawehner |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedWould be cool IMO to paste the view yaml into the bug report so we can skip creating the view. Hope we get there one day.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedIt looks like the value used in the call to entity_load is an array when it should be a simple value. Additionally, if the value couldn't be found, entity_load returns FALSE, so the call to ->label() was failing in those cases.
Comment #3
tstoecklerThe patch makes it return a boolean, though. I think the code should be something like
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedGood catch! Rerolled.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedChanged last return value for clarity.
Comment #7
tim.plunkett#5: drupal-1995868-05-Role-Contextual-Filter-WSOD.patch queued for re-testing.
Comment #8
tstoecklerLooks good to me, but I don't know Views enough to RTBC myself.
Comment #9
andymartha CreditAttribution: andymartha commentedOn a standard download of Drupal 8, the steps outlined in the issue summary by xjm produced a white screen of death for me. See screenshot.
After applying patch drupal-1995868-05-Role-Contextual-Filter-WSOD.patch from #5 by JoshuaRogers to a fresh Drupal 8 install, the path correctly gave me the view in Drupal instead of the WSOD. See screenshot with no perceived detriment in functionality. Good job!
Comment #10
alexpottWe need a test for this...
Comment #11
dawehnerLet's phpunit that!
Comment #12
dawehnerComment #13
katbailey CreditAttribution: katbailey commentedJust a couple of comments about the test as I was chatting with dawehner in irc about it...
I'd prefer a comment here about what we're actually doing, rather than about how PHPUnit behaves, e.g. "Create a stub role storage controller that replaces the attachLoad method."
Why is this needed? I thought our PHPUnit tests could be a container-free zone. Wah.
Comment #14
dawehnerSadly not at the moment but I think there is no reason to not inject it all the time?
Comment #15
tim.plunkettNice!
Missing @var
{@inheritdoc
Where are these used?
Comment #16
dawehnerUps.
Comment #17
dawehnerComment #18
tim.plunkettThanks, looks great!
Comment #19
xjmReroll plus some comment cleanup. I also filed a followup: #2015535: Improve instantiation of entity classes and entity controllers.
Comment #20
xjmJust realized there was never a test-only patch uploaded here. Attached should expose the coverage.
Comment #21
alexpottCommitted 5bf482f and pushed to 8.x. Thanks!
Comment #22
ParisLiakos CreditAttribution: ParisLiakos commentedfollowup #2017449: Drupal\Tests\user\Views\Argument\RolesRidTest is in the wrong place