API page: https://api.drupal.org/api/drupal/core%21modules%21block%21block.api.php...
$build['#contexts'][] = 'user';
should be
$build['#cache']['contexts'][] = 'user';
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | mistake_in-2828372-2.patch | 558 bytes | Sut3kh |
API page: https://api.drupal.org/api/drupal/core%21modules%21block%21block.api.php...
$build['#contexts'][] = 'user';
should be
$build['#cache']['contexts'][] = 'user';
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | mistake_in-2828372-2.patch | 558 bytes | Sut3kh |
Comments
Comment #2
Sut3kh commentedComment #3
chi commentedComment #6
xjmThe documentation also says:
So based on that, there is indeed no way that the current example can be correct. I also compared to other references to this in core:
So that also supports the correction. All the documentation for the hook was added in #2543340: Convert BlockViewBuilder to use #lazy_builder (but don't yet let context-aware blocks be placeholdered) and has not changed since, so it looks like it was just a typo in the original patch (which in fact even added the usage in
block_test.modulethat the hook docs contradicted).Committed and pushed to 8.3.x and 8.2.x. Thanks!