Commit 1dbabcaa authored by alexpott's avatar alexpott

Issue #2181775 by Ryan Weal, chx | mvc: Fixed SQL idmap broke when using...

Issue #2181775 by Ryan Weal, chx | mvc: Fixed SQL idmap broke when using separate mysql users for source and destination.
parent 1623fcc2
......@@ -219,7 +219,7 @@ public function getQualifiedMapTableName() {
* @return \Drupal\Core\Database\Connection
* The database connection object.
*/
protected function getDatabase() {
public function getDatabase() {
if (!isset($this->database)) {
$this->database = \Drupal::database();
}
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Database\Database;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\migrate\id_map\Sql;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
/**
......@@ -116,7 +117,7 @@ protected function runQuery() {
// OR above highwater).
$conditions = $this->query->orConditionGroup();
$condition_added = FALSE;
if ($this->getIds() && ($this->migration->getIdMap() instanceof \Drupal\migrate\Plugin\migrate\id_map\Sql)) {
if ($this->mapJoinable()) {
// Build the join to the map table. Because the source key could have
// multiple fields, we need to build things up.
$count = 1;
......@@ -192,4 +193,21 @@ public function getIterator() {
return $this->iterator;
}
protected function mapJoinable() {
if (!$this->getIds()) {
return FALSE;
}
$id_map = $this->migration->getIdMap();
if (!$id_map instanceof Sql) {
return FALSE;
}
$id_map_database_options = $id_map->getDatabase()->getConnectionOptions();
$source_database_options = $this->getDatabase()->getConnectionOptions();
foreach (array('username', 'password', 'host', 'port', 'namespace', 'driver') as $key) {
if ($id_map_database_options[$key] != $source_database_options[$key]) {
return FALSE;
}
}
return TRUE;
}
}
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