Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
contextual.module
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
22 Jul 2013 at 15:06 UTC
Updated:
29 Jul 2014 at 22:41 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
wim leers#2049601: Contextual links present an empty links trigger when no link items are available for an entity was marked as a duplicate of this issue.
There, it was also said that this can no longer be reproduced.
Comment #2
wim leersI can reproduce this using the same steps xjm provided in the issue summary, but instead of looking at the Tools menu, just look at the contextual link for the front page view.
This super simple patch fixes the problem :)
Comment #3
jessebeach commentedI was able to reproduce following xjm's STR. This is what the object of contextual links looks like for an authenticated person with contextual link permission, but no editing permissions:
And this is what the contextual links object looks like for an admin user:
In both cases, a list of ids of editable items is returned. In the case that a user does not have permission to any operation that would introduce a contextual link, the content of that item is returned as an empty string.
In this case, would it not be better to exclude the id from the returned list such that the returned result set would be an empty object for an authenticated user? Here's a patch that does this.
Comment #4
wim leersGood catch! :)
Unfortunately, the answer is "no, we wouldn't want that". Once #2136507: Use client-side cache tags & caching to eliminate 1 HTTP requests/page for rendering Contextual Links lands, the rendered contextual links for each ID will actually be cached on the client-side. By returning the empty string, the client-side cache knows there's nothing there for the user. If we omit the result, then the client-side cache will have to talk to the server every time, over and over again.
Comment #5
jessebeach commentedAh, yes, I knew you'd have a clever reason. Ok, given the need to support cacheing on the client side, the patch in #2 resolves this issue. I've manually tested and there are no behavior regressions.
I am RTBCing contextual_empty-2047671-2.patch (#2)
Comment #7
wim leersRe-uploading the #2 patch that jessebeach RTBC'd, to avoid any confusion.
Comment #8
webchickSorry, this seems to no longer apply.
Patch looks good though. Feel free to knock it back to RTBC when uploading.
Comment #9
Bojhan commentedNice fix :)
Comment #10
nod_Can we add the condition in the hasOwnProperty if? continue can be confusing.
Comment #11
jessebeach commentedRerolled and I've taken nod_'s comment in #10 into account.
Comment #12
nod_All good, that works. Thanks.
Comment #13
webchickCommitted and pushed to 8.x. Thanks!
Comment #14
wim leers