diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php index 2fb8242..0e7b42d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php @@ -7,11 +7,13 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Annotation\Translation; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\TypedData\OptionsProviderInterface; use Drupal\Core\TypedData\DataDefinition; @@ -42,8 +44,10 @@ public static function defaultStorageSettings() { * {@inheritdoc} */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { + // Use TranslationWrapper as those can be called during early bootstrap, + // before the translation system is ready. $properties['value'] = DataDefinition::create('boolean') - ->setLabel(t('Boolean value')); + ->setLabel(new TranslationWrapper('Boolean value')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php index 961eb67..9c81c10 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php @@ -7,9 +7,11 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Annotation\Translation; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Language\LanguageInterface; +use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataReferenceDefinition; @@ -34,12 +36,14 @@ class LanguageItem extends FieldItemBase { * {@inheritdoc} */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { + // Use TranslationWrapper as those can be called during early bootstrap, + // before the translation system is ready. $properties['value'] = DataDefinition::create('string') - ->setLabel(t('Language code')); + ->setLabel(new TranslationWrapper('Language code')); $properties['language'] = DataReferenceDefinition::create('language') - ->setLabel(t('Language object')) - ->setDescription(t('The referenced language')) + ->setLabel(new TranslationWrapper('Language object')) + ->setDescription(new TranslationWrapper('The referenced language')) // The language object is retrieved via the language code. ->setComputed(TRUE) ->setReadOnly(FALSE); diff --git a/core/lib/Drupal/Core/Session/SessionHandler.php b/core/lib/Drupal/Core/Session/SessionHandler.php index 18dc9b2..e4dc829 100644 --- a/core/lib/Drupal/Core/Session/SessionHandler.php +++ b/core/lib/Drupal/Core/Session/SessionHandler.php @@ -78,12 +78,11 @@ public function read($sid) { // Handle the case of first time visitors and clients that don't store // cookies (eg. web crawlers). - $session = ''; $insecure_session_name = $this->sessionManager->getInsecureName(); $cookies = $this->requestStack->getCurrentRequest()->cookies; if (!$cookies->has($this->getName()) && !$cookies->has($insecure_session_name)) { $user = new AnonymousUserSession(); - return $session; + return ''; } // Otherwise, if the session is still active, we have a record of the @@ -126,17 +125,13 @@ public function read($sid) { if ($user->isBlocked()) { $user = NULL; } - else { - $session = $values['session']; - } } if (!$user && $values) { - // The user is anonymous or blocked. Only preserve two fields from the + // The user is anonymous or blocked. Only preserve the timestamp from the // {sessions} table. $user = new UserSession(array( - 'session' => $values['session'], - 'access' => $values['access'], + 'access' => $values['timestamp'], )); } elseif (!$user) { @@ -144,7 +139,7 @@ public function read($sid) { $user = new AnonymousUserSession(); } - return $session; + return isset($values['session']) ? $values['session'] : ''; } /**