Skip to content
Snippets Groups Projects
Unverified Commit 08350aec authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3178966 by quietone, huzooka, ravi.shankar, Wim Leers: Fatal error in...

Issue #3178966 by quietone, huzooka, ravi.shankar, Wim Leers: Fatal error in CommentEntityTranslation @MigrationSource when source site does not have comment or node module installed
parent 197b2406
No related branches found
No related tags found
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!16Draft: Resolve #2081585 "History storage"
......@@ -2,6 +2,7 @@
namespace Drupal\comment\Plugin\migrate\source\d7;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
......@@ -100,4 +101,20 @@ public function getIds() {
];
}
/**
* {@inheritdoc}
*/
public function checkRequirements() {
parent::checkRequirements();
if (!$this->moduleExists('comment')) {
// If we make it to here, the comment module isn't installed.
throw new RequirementsException('The module comment is not enabled in the source site');
}
if (!$this->moduleExists('node')) {
// Node module is also a requirement.
throw new RequirementsException('The module node is not enabled in the source site');
}
}
}
<?php
namespace Drupal\Tests\comment\Kernel\Migrate\d7;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\migrate\Exception\RequirementsException;
/**
* Tests check requirements for comment entity translation source plugin.
*
* @group comment
*/
class CommentEntityTranslationCheckRequirementsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'content_translation',
'comment',
'language',
];
/**
* Tests exception thrown when the given module is not enabled in the source.
*
* @dataProvider providerTestCheckRequirements
*/
public function testCheckRequirements($module) {
// Disable the module in the source site.
$this->sourceDatabase->update('system')
->condition('name', $module)
->fields([
'status' => '0',
])
->execute();
$this->expectException(RequirementsException::class);
$this->expectExceptionMessage("The module $module is not enabled in the source site");
$this->getMigration('d7_comment_entity_translation')
->getSourcePlugin()
->checkRequirements();
}
/**
* Provides data for testCheckRequirements.
*
* @return string[][]
*/
public function providerTestCheckRequirements() {
return [
['comment'],
['node'],
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment