Commit 358989ea authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2918837 by heddn, neclimdul, phenaproxima, quietone, Gábor Hojtsy:...

Issue #2918837 by heddn, neclimdul, phenaproxima, quietone, Gábor Hojtsy: SqlBase throws fatal error when extended directly
parent 1e2583bb
......@@ -216,7 +216,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
/**
* Initializes the iterator with the source data.
*
* @return array
* @return \Iterator
* An array of the data for this source.
*/
abstract protected function initializeIterator();
......
......@@ -346,7 +346,9 @@ protected function initializeIterator() {
if (($this->batchSize > 0)) {
$this->query->range($this->batch * $this->batchSize, $this->batchSize);
}
return new \IteratorIterator($this->query->execute());
$statement = $this->query->execute();
$statement->setFetchMode(\PDO::FETCH_ASSOC);
return new \IteratorIterator($statement);
}
/**
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Database\Query\ConditionInterface;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Database\StatementInterface;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\Core\Database\Database;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
......@@ -149,10 +150,10 @@ public function testHighWater($high_water = NULL, array $query_result = []) {
$source->getHighWaterStorage()->set($this->migration->id(), $high_water);
}
$query_result = new \ArrayIterator($query_result);
$query = $this->getMock(SelectInterface::class);
$query->method('execute')->willReturn($query_result);
$statement = $this->createMock(StatementInterface::class);
$statement->expects($this->atLeastOnce())->method('setFetchMode')->with(\PDO::FETCH_ASSOC);
$query = $this->createMock(SelectInterface::class);
$query->method('execute')->willReturn($statement);
$query->expects($this->atLeastOnce())->method('orderBy')->with('order', 'ASC');
$condition_group = $this->getMock(ConditionInterface::class);
......
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