Commit a1a92972 authored by catch's avatar catch
Browse files

Issue #3261243 by andypost, longwave: Remove deprecated comment module functions

parent 6385a8fd
Loading
Loading
Loading
Loading
+0 −43
Original line number Diff line number Diff line
@@ -53,49 +53,6 @@ public function prepareRow(Row $row) {
    return parent::prepareRow($row);
  }

  /**
   * Provides a BC layer for deprecated sources.
   *
   * @param \Drupal\migrate\Row $row
   *   The row from the source to process.
   *
   * @return \Drupal\migrate\Row
   *   The row object.
   *
   * @throws \Exception
   *   Passing a Row with a frozen source to this method will trigger an
   *   \Exception when attempting to set the source properties.
   *
   * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. No direct
   *   replacement is provided.
   *
   * @see https://www.drupal.org/node/3221964
   */
  protected function prepareComment(Row $row) {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3221964', E_USER_DEPRECATED);
    if ($this->variableGet('comment_subject_field_' . $row->getSourceProperty('type'), 1)) {
      // Comment subject visible.
      $row->setSourceProperty('field_name', 'comment');
      $row->setSourceProperty('comment_type', 'comment');
    }
    else {
      $row->setSourceProperty('field_name', 'comment_no_subject');
      $row->setSourceProperty('comment_type', 'comment_no_subject');
    }

    // In D6, status=0 means published, while in D8 means the opposite.
    // See https://www.drupal.org/node/237636.
    $row->setSourceProperty('status', !$row->getSourceProperty('status'));

    // If node did not have a language, use site default language as a fallback.
    if (!$row->getSourceProperty('language')) {
      $language_default = $this->variableGet('language_default', NULL);
      $language = $language_default ? $language_default->language : 'en';
      $row->setSourceProperty('language', $language);
    }
    return $row;
  }

  /**
   * {@inheritdoc}
   */
+0 −7
Original line number Diff line number Diff line
name: Drupal 6 comment test
type: module
description: Provides a source plugin to test prepareComment deprecation.
package: Testing
version: VERSION
dependencies:
  - drupal:comment
+0 −25
Original line number Diff line number Diff line
<?php

namespace Drupal\d6_comment_test\Plugin\migrate\source\d6;

use Drupal\comment\Plugin\migrate\source\d6\Comment as CoreComment;
use Drupal\migrate\Row;

/**
 * Test source plugin for deprecation testing.
 *
 * @MigrateSource(
 *   id = "d6_comment_test",
 *   source_module = "comment"
 * )
 */
class Comment extends CoreComment {

  /**
   * Allow access to protected method.
   */
  public function prepareComment(Row $row) {
    return parent::prepareComment($row);
  }

}
+1 −13
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d6;

use Drupal\migrate\Row;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;

/**
@@ -16,18 +15,7 @@ class CommentTest extends MigrateSqlSourceTestBase {
  /**
   * {@inheritdoc}
   */
  protected static $modules = ['comment', 'd6_comment_test', 'migrate_drupal'];

  /**
   * @group legacy
   */
  public function testPrepareCommentDeprecation() {
    $this->expectDeprecation('Drupal\comment\Plugin\migrate\source\d6\Comment::prepareComment() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3221964');
    $migration = $this->createMock('Drupal\migrate\Plugin\MigrationInterface');
    $mgr = \Drupal::service('plugin.manager.migrate.source');
    $plugin = $mgr->createInstance('d6_comment_test', [], $migration);
    $plugin->prepareComment(new Row());
  }
  protected static $modules = ['comment', 'migrate_drupal'];

  /**
   * {@inheritdoc}