Skip to content

Commit

Permalink
PHP 7.X - appending an array to an ArrayObject by reference is not po…
Browse files Browse the repository at this point in the history
…ssible anymore

There was 1 failure:
1) PropelArrayFormatterWithTest::testFindOneWithOneToMany
Related objects are correctly hydrated
Failed asserting that 1 matches expected 2.

PHP 7.X - appending an array to an ArrayObject by reference is not possible anymore

Fix taken from : https://github.com/raebbar/propel/releases/tag/1.7.2
  • Loading branch information
Jean-Michael committed Nov 6, 2017
1 parent 8b6a304 commit 456da90
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions runtime/lib/formatter/PropelArrayFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,23 @@ class PropelArrayFormatter extends PropelFormatter
public function format(PDOStatement $stmt)
{
$this->checkInit();
if ($class = $this->collectionName) {
$collection = new $class();
$collection->setModel($this->class);
$collection->setFormatter($this);
} else {
$collection = array();
}
$collection = array();

if ($this->isWithOneToMany() && $this->hasLimit) {
throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.');
}
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
if ($object = &$this->getStructuredArrayFromRow($row)) {
$collection[] = $object;
$collection[] =& $object;
}
}

if ($class = $this->collectionName) {
$collection = new $class($collection);
$collection->setModel($this->class);
$collection->setFormatter($this);
}

$this->currentObjects = array();
$this->alreadyHydratedObjects = array();
$stmt->closeCursor();
Expand Down

0 comments on commit 456da90

Please sign in to comment.