From cd1b26d91fb895cb7248310351c586826fdde008 Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Fri, 11 Mar 2022 15:05:36 +0100 Subject: [PATCH 1/4] Extend prepareRow: remove not foud entity --- src/Actions/Processors/AbstractBaseProcessor.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Actions/Processors/AbstractBaseProcessor.php b/src/Actions/Processors/AbstractBaseProcessor.php index 5edae73d..afa9ee9f 100644 --- a/src/Actions/Processors/AbstractBaseProcessor.php +++ b/src/Actions/Processors/AbstractBaseProcessor.php @@ -182,12 +182,21 @@ protected function getPreparedStatements() * * @return array The prepared row */ - protected function prepareRow(array $row) + protected function prepareRow(array $row, $statement = '') { // remove the entity status unset($row[EntityStatus::MEMBER_NAME]); + // Remove unused rows from statement + if (!empty($statement)) { + foreach($row as $key => $value) { + if (!preg_match('/(:'.$key.'[^a-zA-Z_])|(:'.$key.'$)/', $statement)) { + unset($row[$key]); + } + } + } + // return the prepared row return $row; } @@ -219,7 +228,7 @@ public function execute($row, $name = null, $primaryKeyMemberName = null) try { // finally execute the prepared statement - $statement->execute($this->prepareRow($row)); + $statement->execute($this->prepareRow($row, $statement->queryString)); } catch (\PDOException $pdoe) { // initialize the SQL statement with the placeholders $sql = $statement->queryString; From c14653c911f4732b2203b2484a70bc41df492527 Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Fri, 11 Mar 2022 15:11:23 +0100 Subject: [PATCH 2/4] fix style code --- src/Actions/Processors/AbstractBaseProcessor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Actions/Processors/AbstractBaseProcessor.php b/src/Actions/Processors/AbstractBaseProcessor.php index afa9ee9f..f23b33db 100644 --- a/src/Actions/Processors/AbstractBaseProcessor.php +++ b/src/Actions/Processors/AbstractBaseProcessor.php @@ -179,6 +179,7 @@ protected function getPreparedStatements() * entity status. * * @param array $row The row to prepare + * @param string $statement The statement string * * @return array The prepared row */ @@ -190,7 +191,7 @@ protected function prepareRow(array $row, $statement = '') // Remove unused rows from statement if (!empty($statement)) { - foreach($row as $key => $value) { + foreach ($row as $key => $value) { if (!preg_match('/(:'.$key.'[^a-zA-Z_])|(:'.$key.'$)/', $statement)) { unset($row[$key]); } From 59afabc5df173330b912a50267f87d202c3af53c Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Fri, 11 Mar 2022 15:20:12 +0100 Subject: [PATCH 3/4] update changlog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34ad2592..75714a53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# Version 16.8.12 + +## Improvement + +* None + +## Bugfixes + +* Extend prepareRow() method remove not foud entities + # Version 16.8.11 ## Improvement From dbb261b273813c4e88f0a20a65ad93747e652afb Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Fri, 11 Mar 2022 15:21:18 +0100 Subject: [PATCH 4/4] fix style code --- src/Actions/Processors/AbstractBaseProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Actions/Processors/AbstractBaseProcessor.php b/src/Actions/Processors/AbstractBaseProcessor.php index f23b33db..f93bb676 100644 --- a/src/Actions/Processors/AbstractBaseProcessor.php +++ b/src/Actions/Processors/AbstractBaseProcessor.php @@ -178,7 +178,7 @@ protected function getPreparedStatements() * Prepare's and return's the passed row by removing the * entity status. * - * @param array $row The row to prepare + * @param array $row The row to prepare * @param string $statement The statement string * * @return array The prepared row