Issue #2918837 by heddn, neclimdul, phenaproxima, quietone, Gábor Hojtsy: SqlBase throws fatal error when extended directly
parent
1e2583bb31
commit
358989eaa1
|
@ -216,7 +216,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
|
|||
/**
|
||||
* 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 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
|
|||
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 @@ namespace Drupal\Tests\migrate\Kernel;
|
|||
|
||||
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 @@ class SqlBaseTest extends MigrateTestBase {
|
|||
$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);
|
||||
|
|
Loading…
Reference in New Issue