Fix various bugs in the import routine, discovered by Doug.

This commit is contained in:
James Cole
2018-06-13 19:03:18 +02:00
parent f4b66b980b
commit 477a3c7eb2
10 changed files with 50 additions and 7 deletions

View File

@@ -279,11 +279,14 @@ class ImportableConverter
*/
private function verifyObjectId(string $key, int $objectId): ?int
{
if (isset($this->mappedValues[$key]) && \in_array($objectId, $this->mappedValues[$key], true)) {
Log::debug(sprintf('verifyObjectId(%s, %d) is valid!',$key, $objectId));
return $objectId;
}
return null;
Log::debug(sprintf('verifyObjectId(%s, %d) is NOT in the list, but it could still be valid.',$key, $objectId));
return $objectId;
}

View File

@@ -87,6 +87,7 @@ class MappedValuesValidator
$return = [];
Log::debug('Now in validateMappedValues()');
foreach ($mappings as $role => $values) {
Log::debug(sprintf('Now at role "%s"', $role));
$values = array_unique($values);
if (\count($values) > 0) {
switch ($role) {
@@ -115,9 +116,11 @@ class MappedValuesValidator
$return[$role] = $valid;
break;
case 'category-id':
Log::debug('Going to validate these category ids: ', $values);
$set = $this->catRepos->getByIds($values);
$valid = $set->pluck('id')->toArray();
$return[$role] = $valid;
Log::debug('Valid category IDs are: ', $valid);
break;
}
}