Skip to content

Commit be7dc58

Browse files
author
aude
committed
Check for null entity id in StatementsImporter
1 parent afd0806 commit be7dc58

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/StatementsImporter.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,22 @@ public function importStatements( EntityDocument $entity ) {
5050
$this->logger->info( 'Adding statements: ' . $entity->getId()->getSerialization() );
5151

5252
if ( !$statements->isEmpty() ) {
53-
$localId = $this->entityMappingStore->getLocalId( $entity->getId() );
54-
55-
if ( !$localId ) {
56-
$this->logger->error( $entity->getId()->getSerialization() . ' not found' );
57-
}
58-
59-
try {
60-
$this->addStatementList( $localId, $statements );
61-
} catch ( \Exception $ex ) {
62-
$this->logger->error( $ex->getMessage() );
53+
$entityId = $entity->getId();
54+
55+
if ( $entityId instanceof EntityId ) {
56+
$localId = $this->entityMappingStore->getLocalId( $entityId );
57+
58+
if ( !$localId ) {
59+
$this->logger->error( $entityId->getSerialization() . ' not found' );
60+
}
61+
62+
try {
63+
$this->addStatementList( $localId, $statements );
64+
} catch ( \Exception $ex ) {
65+
$this->logger->error( $ex->getMessage() );
66+
}
67+
} else {
68+
$this->logger->error( 'EntityId not set for entity' );
6369
}
6470
}
6571
}

0 commit comments

Comments
 (0)