Commit d74e36a4 authored by catch's avatar catch

Issue #2859315 by quietone, heddn, jhodgdon: SQL error from profile_fields...

Issue #2859315 by quietone, heddn, jhodgdon: SQL error from profile_fields when migrating d6 (or d7) to d8 without Profile module
parent 3cc8a612
......@@ -78,7 +78,6 @@ protected function getAvailablePaths() {
'options',
'path',
'phone',
'profile',
'rdf',
'search',
'shortcut',
......@@ -158,6 +157,7 @@ protected function getMissingPaths() {
'i18n_translation',
'i18n_user',
'i18n_variable',
'profile',
'variable',
'variable_admin',
'variable_realm',
......
......@@ -2,6 +2,7 @@
namespace Drupal\user\Plugin\migrate\source;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;
......@@ -33,16 +34,7 @@ class ProfileField extends DrupalSqlBase {
* {@inheritdoc}
*/
public function query() {
if (empty($this->fieldTable) || empty($this->valueTable)) {
if ($this->getModuleSchemaVersion('system') >= 7000) {
$this->fieldTable = 'profile_field';
$this->valueTable = 'profile_value';
}
else {
$this->fieldTable = 'profile_fields';
$this->valueTable = 'profile_values';
}
}
$this->setTableNames();
return $this->select($this->fieldTable, 'pf')->fields('pf');
}
......@@ -105,4 +97,32 @@ public function getIds() {
return $ids;
}
/**
* {@inheritdoc}
*/
public function checkRequirements() {
$this->setTableNames();
if (!$this->getDatabase()->schema()->tableExists($this->fieldTable)) {
// If we make it to here, the profile module isn't installed.
throw new RequirementsException('Profile module not enabled on source site');
}
parent::checkRequirements();
}
/**
* Helper to set the profile field table names.
*/
protected function setTableNames() {
if (empty($this->fieldTable) || empty($this->valueTable)) {
if ($this->getModuleSchemaVersion('system') >= 7000) {
$this->fieldTable = 'profile_field';
$this->valueTable = 'profile_value';
}
else {
$this->fieldTable = 'profile_fields';
$this->valueTable = 'profile_values';
}
}
}
}
<?php
namespace Drupal\Tests\user\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
use Drupal\migrate\Exception\RequirementsException;
/**
* Tests check requirements for profile_field source plugin.
*
* @group user
*/
class ProfileFieldCheckRequirementsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public function setup() {
parent::setUp();
$this->sourceDatabase->schema()->dropTable('profile_fields');
}
/**
* Tests exception in thrown when profile_fields tables does not exist.
*/
public function testCheckRequirements() {
$this->setExpectedException(RequirementsException::class, 'Profile module not enabled on source site');
$this->getMigration('user_profile_field')
->getSourcePlugin()
->checkRequirements();
}
}
<?php
namespace Drupal\Tests\user\Kernel\Migrate\d7;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\migrate\Exception\RequirementsException;
/**
* Tests check requirements for profile_field source plugin.
*
* @group user
*/
class ProfileFieldCheckRequirementsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public function setup() {
parent::setUp();
$this->sourceDatabase->schema()->dropTable('profile_field');
}
/**
* Tests exception in thrown when profile_fields tables does not exist.
*/
public function testCheckRequirements() {
$this->setExpectedException(RequirementsException::class, 'Profile module not enabled on source site');
$this->getMigration('user_profile_field')
->getSourcePlugin()
->checkRequirements();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment