From 8af65a99c416643613bde7c5896aa33bfd475660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 16 Jan 2022 21:38:24 +0100 Subject: [PATCH] initialize filter iterator by default --- src/Persistence/Array_.php | 2 -- src/Persistence/Array_/Action.php | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Persistence/Array_.php b/src/Persistence/Array_.php index 697fe8f07..32b8f9dbe 100644 --- a/src/Persistence/Array_.php +++ b/src/Persistence/Array_.php @@ -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) { @@ -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) { diff --git a/src/Persistence/Array_/Action.php b/src/Persistence/Array_/Action.php index 4b692458a..9e432fd53 100644 --- a/src/Persistence/Array_/Action.php +++ b/src/Persistence/Array_/Action.php @@ -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;