Skip to content

Commit 58b8ea2

Browse files
authored
Merge pull request #229 from techdivision/extend-import
2 parents ef6ea9c + dbb261b commit 58b8ea2

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Version 16.8.12
2+
3+
## Improvement
4+
5+
* None
6+
7+
## Bugfixes
8+
9+
* Extend prepareRow() method remove not foud entities
10+
111
# Version 16.8.11
212

313
## Improvement

src/Actions/Processors/AbstractBaseProcessor.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,26 @@ protected function getPreparedStatements()
178178
* Prepare's and return's the passed row by removing the
179179
* entity status.
180180
*
181-
* @param array $row The row to prepare
181+
* @param array $row The row to prepare
182+
* @param string $statement The statement string
182183
*
183184
* @return array The prepared row
184185
*/
185-
protected function prepareRow(array $row)
186+
protected function prepareRow(array $row, $statement = '')
186187
{
187188

188189
// remove the entity status
189190
unset($row[EntityStatus::MEMBER_NAME]);
190191

192+
// Remove unused rows from statement
193+
if (!empty($statement)) {
194+
foreach ($row as $key => $value) {
195+
if (!preg_match('/(:'.$key.'[^a-zA-Z_])|(:'.$key.'$)/', $statement)) {
196+
unset($row[$key]);
197+
}
198+
}
199+
}
200+
191201
// return the prepared row
192202
return $row;
193203
}
@@ -219,7 +229,7 @@ public function execute($row, $name = null, $primaryKeyMemberName = null)
219229

220230
try {
221231
// finally execute the prepared statement
222-
$statement->execute($this->prepareRow($row));
232+
$statement->execute($this->prepareRow($row, $statement->queryString));
223233
} catch (\PDOException $pdoe) {
224234
// initialize the SQL statement with the placeholders
225235
$sql = $statement->queryString;

0 commit comments

Comments
 (0)