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

merge-requests/1789/head
catch 2022-02-07 13:27:24 +00:00
parent 6385a8fd92
commit a1a929726f
4 changed files with 1 additions and 88 deletions

View File

@ -53,49 +53,6 @@ class Comment extends DrupalSqlBase {
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}
*/

View File

@ -1,7 +0,0 @@
name: Drupal 6 comment test
type: module
description: Provides a source plugin to test prepareComment deprecation.
package: Testing
version: VERSION
dependencies:
- drupal:comment

View File

@ -1,25 +0,0 @@
<?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);
}
}

View File

@ -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}