Issue #2936642 by tim.plunkett: Getting runtime contexts will generate an E_WARNING for anonymous users

merge-requests/1654/head
Lee Rowlands 2018-02-05 07:11:18 +10:00
parent 40af3f5ad2
commit c3ebbc485b
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
1 changed files with 5 additions and 3 deletions

View File

@ -50,9 +50,11 @@ class CurrentUserContext implements ContextProviderInterface {
public function getRuntimeContexts(array $unqualified_context_ids) {
$current_user = $this->userStorage->load($this->account->id());
// @todo Do not validate protected fields to avoid bug in TypedData, remove
// this in https://www.drupal.org/project/drupal/issues/2934192.
$current_user->_skipProtectedUserFieldConstraint = TRUE;
if ($current_user) {
// @todo Do not validate protected fields to avoid bug in TypedData,
// remove this in https://www.drupal.org/project/drupal/issues/2934192.
$current_user->_skipProtectedUserFieldConstraint = TRUE;
}
$context = new Context(new ContextDefinition('entity:user', $this->t('Current user')), $current_user);
$cacheability = new CacheableMetadata();