Add a group formatter for easier subscribe/ unsubscribe #141
Conversation
…ttingsSummary method
|
I have reviewed around half of the PR now. I have also tested it, but I seem to encounter some problems.
I have to stop for today, work is calling. Will continue review as soon as I find some time. |
|
So the extensive test coverage has uncovered a bug in Drupal core regarding upcasting of entities with an invalid entity type ID. Created bug report: https://www.drupal.org/node/2786897 |
…g into 40-group-formatter-unit-tests
|
Thanks for the 1st half of the review! (And thanks for doing the code changes) Cool, I didn't know you can upcast by |
|
Tests seem to fail over new code sniffer fixes. I suspect these are new sniffer rules :/ |
|
I'll lock the PHPCS version in travis, as fixing "new" sniffer errors is out of scope for this PR. |
|
I'll work on adapting the unit tests that are now failing due to the new injections |
|
Yeah the code sniffer was set to the latest dev version, that has a potential to break builds on a daily basis if they make new updates. I had also identified this and addressed it in amitaibu#301 It's good to have it in here too though. |
| // We cannot use the field cache, as the formatter changes according to the | ||
| // user. Furthermore, this is not an expensive check, so we remove the cache | ||
| // entirely. | ||
| $elements['#cache']['max-age'] = 0; |
There was a problem hiding this comment.
Won't this bubble up, and make the whole entity view un-cachable?
There was a problem hiding this comment.
I'm not sure - and I actually don't know exactly how to verify it. Need to do some digging 😉 @pfrenssen do you happen to know how to check it?
|
Very good find! I just checked it and this indeed bubbles up to make the entire page uncacheable. To solve it correctly we should use a cache context for the users status in the group, but we don't have this yet. For the moment, let's vary the cache context by user - that is a bit too broad but it will work for now without killing caching. Let's be sure to leave a todo in the code too so we remember to address this properly once we have an Now, how to check cacheability. The easiest way is by enabling the Dynamic Page Cache module and setting up the cacheability debug headers:
Currently with the cache max-age set to 0 this displays Unfortunately the dynamic page cache module also considers render elements that vary by the user or session to be This is due to the default settings for auto-placeholdering, also in So with these default settings if the cache context is set to 'user' then the page will not be cached. This is because it is considered too granular. I think maybe we should split this up to a followup. We need to make this |
|
Thanks for the great explanation on how to check the cache! I've opened #150. For now I think we should go with the no cache option, as the So adding the proper OgMembership cache context would be done in a follow up. |
|
(also, re-rolled) |
|
The failing test appears to be just due to a missed instance of |
|
Correct, thanks. I've converted another old method call to groupTypeManager. |
|
I'll merge this tomorrow, as I'd be happy to get those basic things in. We can always revisit as needed. |
|
Thanks all! |
Continue work from amitaibu#40