reverted: --- b/core/modules/node/src/Access/NodeRevisionAccessCheck.php +++ a/core/modules/node/src/Access/NodeRevisionAccessCheck.php @@ -70,20 +70,16 @@ * revision when $node_revision is unspecified. Ignored when $node_revision * is specified. If neither $node_revision nor $node are specified, then * access is denied. - * @param string|null $langcode - * (optional) Language code for the variant of the node. Different language - * variants might have different permissions associated. If NULL, the - * original langcode of the node is used. Defaults to NULL. * * @return \Drupal\Core\Access\AccessResultInterface * The access result. */ + public function access(Route $route, AccountInterface $account, $node_revision = NULL, NodeInterface $node = NULL) { - public function access(Route $route, AccountInterface $account, $node_revision = NULL, NodeInterface $node = NULL, $langcode = NULL) { if ($node_revision) { $node = $this->nodeStorage->loadRevision($node_revision); } $operation = $route->getRequirement('_access_node_revision'); + return AccessResult::allowedIf($node && $this->checkAccess($node, $account, $operation))->cachePerPermissions(); - return AccessResult::allowedIf($node && $this->checkAccess($node, $account, $operation, $langcode))->cachePerPermissions(); } /** diff -u b/core/modules/node/src/Form/NodeRevisionRevertForm.php b/core/modules/node/src/Form/NodeRevisionRevertForm.php --- b/core/modules/node/src/Form/NodeRevisionRevertForm.php +++ b/core/modules/node/src/Form/NodeRevisionRevertForm.php @@ -7,6 +7,7 @@ namespace Drupal\node\Form; +use Drupal\Core\Datetime\DateFormatter; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\FormStateInterface; @@ -34,13 +35,23 @@ protected $nodeStorage; /** + * The date formatter service. + * + * @var \Drupal\Core\Datetime\DateFormatter + */ + protected $dateFormatter; + + /** * Constructs a new NodeRevisionRevertForm. * * @param \Drupal\Core\Entity\EntityStorageInterface $node_storage * The node storage. + * @param \Drupal\Core\Datetime\DateFormatter $date_formatter + * The date formatter service. */ - public function __construct(EntityStorageInterface $node_storage) { + public function __construct(EntityStorageInterface $node_storage, DateFormatter $date_formatter) { $this->nodeStorage = $node_storage; + $this->dateFormatter = $date_formatter; } /** @@ -48,7 +59,8 @@ */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorage('node') + $container->get('entity.manager')->getStorage('node'), + $container->get('date.formatter') ); } @@ -63,7 +75,7 @@ * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($this->revision->getRevisionCreationTime()))); + return t('Are you sure you want to revert to the revision from %revision-date?', ['%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime())]); } /** @@ -106,11 +118,11 @@ $original_revision_timestamp = $this->revision->getRevisionCreationTime(); $this->revision = $this->prepareRevertedRevision($this->revision, $form_state); - $this->revision->revision_log = t('Copy of the revision from %date.', array('%date' => \Drupal::service('date.formatter')->format($original_revision_timestamp))); + $this->revision->revision_log = t('Copy of the revision from %date.', ['%date' => $this->dateFormatter->format($original_revision_timestamp)]); $this->revision->save(); - $this->logger('content')->notice('@type: reverted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId())); - drupal_set_message(t('@type %title has been reverted to the revision from %revision-date.', array('@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => \Drupal::service('date.formatter')->format($original_revision_timestamp)))); + $this->logger('content')->notice('@type: reverted %title revision %revision.', ['@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); + drupal_set_message(t('@type %title has been reverted to the revision from %revision-date.', ['@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)])); $form_state->setRedirect( 'entity.node.version_history', array('node' => $this->revision->id()) diff -u b/core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php b/core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php --- b/core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php +++ b/core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php @@ -7,6 +7,7 @@ namespace Drupal\node\Form; +use Drupal\Core\Datetime\DateFormatter; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface; @@ -37,11 +38,13 @@ * * @param \Drupal\Core\Entity\EntityStorageInterface $node_storage * The node storage. + * @param \Drupal\Core\Datetime\DateFormatter $date_formatter + * The date formatter service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ - public function __construct(EntityStorageInterface $node_storage, LanguageManagerInterface $language_manager) { - parent::__construct($node_storage); + public function __construct(EntityStorageInterface $node_storage, DateFormatter $date_formatter, LanguageManagerInterface $language_manager) { + parent::__construct($node_storage, $date_formatter); $this->languageManager = $language_manager; } @@ -51,6 +54,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager')->getStorage('node'), + $container->get('date.formatter'), $container->get('language_manager') ); } @@ -66,7 +70,7 @@ * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to revert @language translation to the revision from %revision-date?', ['@language' => $this->languageManager->getLanguageName($this->langcode), '%revision-date' => format_date($this->revision->getRevisionCreationTime())]); + return t('Are you sure you want to revert @language translation to the revision from %revision-date?', ['@language' => $this->languageManager->getLanguageName($this->langcode), '%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime())]); } /** @@ -85,7 +89,7 @@ $form['revert_untranslated_fields'] = array( '#type' => 'checkbox', - '#title' => $this->t('Revert untranslated fields.'), + '#title' => $this->t('Revert content shared among translations'), '#default_value' => FALSE, ); diff -u b/core/modules/node/src/Tests/NodeRevisionsTest.php b/core/modules/node/src/Tests/NodeRevisionsTest.php --- b/core/modules/node/src/Tests/NodeRevisionsTest.php +++ b/core/modules/node/src/Tests/NodeRevisionsTest.php @@ -8,6 +8,8 @@ namespace Drupal\node\Tests; use Drupal\Core\Url; +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; @@ -42,14 +44,14 @@ 'cardinality' => 1, 'translatable' => FALSE, ); - $field_storage = entity_create('field_storage_config', $field_storage_definition); + $field_storage = FieldStorageConfig::create($field_storage_definition); $field_storage->save(); $field_definition = array( 'field_storage' => $field_storage, 'bundle' => 'page', ); - $field = entity_create('field_config', $field_definition); + $field = FieldConfig::create($field_definition); $field->save(); // Create and log in user.