Skip to content

A free open source IT asset/license management system

Add a check to ensure custom fields exist before iterating through them

Daniel Meltzer8c00bad6d0e2
diff --git a/app/Console/Commands/ObjectImportCommand.php b/app/Console/Commands/ObjectImportCommand.php
index b0971f6d1e..0c33bdd5bb 100644
--- a/app/Console/Commands/ObjectImportCommand.php
+++ b/app/Console/Commands/ObjectImportCommand.php
@@ -748,9 +748,11 @@ class ObjectImportCommand extends Command {
$asset->purchase_date = NULL;
}
- foreach ($item['custom_fields'] as $custom_field => $val) {
- $asset->{$custom_field} = $val;
- }
+ if( array_key_exists('custom_fields', $item)) {
+ foreach ($item['custom_fields'] as $custom_field => $val) {
+ $asset->{$custom_field} = $val;
+ }
+ }
if (!empty($item["purchase_cost"])) {
//TODO How to generalize this for not USD?