Skip to content

Commit

Permalink
initialize filter iterator by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jan 17, 2022
1 parent b363b30 commit 8af65a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/Persistence/Array_.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public function tryLoad(Model $model, $id): ?array
{
if ($id === self::ID_LOAD_ONE || $id === self::ID_LOAD_ANY) {
$action = $this->action($model, 'select');
$action->generator->rewind(); // TODO needed for some reasons!

$selectRow = $action->getRow();
if ($selectRow === null) {
Expand All @@ -238,7 +237,6 @@ public function tryLoad(Model $model, $id): ?array
$condition->key = $model->getField($model->id_field);
$condition->setOwner($model->createEntity()); // TODO needed for typecasting to apply
$action->filter($condition);
$action->generator->rewind(); // TODO needed for some reasons!

$rowData = $action->getRow();
if ($rowData === null) {
Expand Down
3 changes: 3 additions & 0 deletions src/Persistence/Array_/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function filter(Model\Scope\AbstractScope $condition)
} else {
$this->generator = new \CallbackFilterIterator($this->generator, $filterFx);
}
// initialize filter iterator, it is not rewound by default
// https://github.com/php/php-src/issues/7952
$this->generator->rewind();
}

return $this;
Expand Down

0 comments on commit 8af65a9

Please sign in to comment.