Unverified Commit 74ddb4b3 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3067361 by mikelutz, Berdir: Properly deprecate NodeType::isNewRevision

parent b5238ac9
Loading
Loading
Loading
Loading
+1 −1
Changes for core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ protected function createContentTypeFromUi($content_type_name, $content_type_id,
    $this->drupalPostForm(NULL, $edit, t('Save content type'));

    // Check the content type has been set to create new revisions.
    $this->assertTrue(NodeType::load($content_type_id)->isNewRevision());
    $this->assertTrue(NodeType::load($content_type_id)->shouldCreateNewRevision());

    if ($moderated) {
      $this->enableModerationThroughUi($content_type_id, $workflow_id);
+3 −2
Changes for core/modules/node/src/Entity/NodeType.php: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -125,7 +125,8 @@ public function isLocked() {
   * {@inheritdoc}
   */
  public function isNewRevision() {
    return $this->new_revision;
    @trigger_error('NodeType::isNewRevision is deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use Drupal\Core\Entity\RevisionableEntityBundleInterface::shouldCreateNewRevision() instead. See https://www.drupal.org/node/3067365', E_USER_DEPRECATED);
    return $this->shouldCreateNewRevision();
  }

  /**
@@ -216,7 +217,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti
   * {@inheritdoc}
   */
  public function shouldCreateNewRevision() {
    return $this->isNewRevision();
    return $this->new_revision;
  }

}
+1 −1
Changes for core/modules/node/src/NodeAccessControlHandler.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ protected function checkFieldAccess($operation, FieldDefinitionInterface $field_
      if ($account->hasPermission('administer nodes')) {
        return AccessResult::allowed()->cachePerPermissions();
      }
      return AccessResult::allowedIf($items->getEntity()->type->entity->isNewRevision())->cachePerPermissions();
      return AccessResult::allowedIf($items->getEntity()->type->entity->shouldCreateNewRevision())->cachePerPermissions();
    }
    return parent::checkFieldAccess($operation, $field_definition, $account, $items);
  }
+1 −1
Changes for core/modules/node/src/NodeTypeForm.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ public function form(array $form, FormStateInterface $form_state) {
      'status' => $node->status->value,
      'promote' => $node->promote->value,
      'sticky' => $node->sticky->value,
      'revision' => $type->isNewRevision(),
      'revision' => $type->shouldCreateNewRevision(),
    ];
    // Prepare workflow options to be used for 'checkboxes' form element.
    $keys = array_keys(array_filter($workflow_options));
+3 −1
Changes for core/modules/node/src/NodeTypeInterface.php: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -24,9 +24,11 @@ public function isLocked();
   * @return bool
   *   TRUE if a new revision should be created by default.
   *
   * @deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. Use
   * @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use
   *   Drupal\Core\Entity\RevisionableEntityBundleInterface::shouldCreateNewRevision()
   *   instead.
   *
   * @see https://www.drupal.org/node/3067365
   */
  public function isNewRevision();

Loading