@@ -269,22 +269,29 @@ public function getDataDictionaryFields(?string $identifier = NULL): ?array {
269
269
*/
270
270
public function drop (string $ identifier , ?string $ version = NULL , bool $ remove_local_resource = TRUE ) {
271
271
if ($ storage = $ this ->getStorage ($ identifier , $ version )) {
272
- $ resource = $ this ->resourceLocalizer ->get ($ identifier , $ version );
273
- // Dispatch the pre-drop event.
274
- $ this ->eventDispatcher ->dispatch (
275
- new DatastorePreDropEvent ($ resource ),
276
- self ::EVENT_DATASTORE_PRE_DROP
277
- );
272
+ $ resource = NULL ;
273
+ // Check for the resource before sending the pre-drop event.
274
+ if ($ resource = $ this ->resourceLocalizer ->get ($ identifier , $ version )) {
275
+ // Dispatch the pre-drop event.
276
+ $ this ->eventDispatcher ->dispatch (
277
+ new DatastorePreDropEvent ($ resource ),
278
+ self ::EVENT_DATASTORE_PRE_DROP
279
+ );
280
+ }
278
281
// Drop.
279
282
$ storage ->destruct ();
280
- // Remove the info from the job store.
281
- $ this ->importJobStoreFactory ->getInstance ()
282
- ->remove (md5 ($ resource ->getUniqueIdentifier ()));
283
- // Dispatch the dropped event.
284
- $ this ->eventDispatcher ->dispatch (
285
- new DatastoreDroppedEvent ($ resource ),
286
- self ::EVENT_DATASTORE_DROPPED
287
- );
283
+ // Check for the resource before removing the job store or sending the
284
+ // dropped event.
285
+ if ($ resource ) {
286
+ // Remove the info from the job store.
287
+ $ this ->importJobStoreFactory ->getInstance ()
288
+ ->remove (md5 ($ resource ->getUniqueIdentifier ()));
289
+ // Dispatch the dropped event.
290
+ $ this ->eventDispatcher ->dispatch (
291
+ new DatastoreDroppedEvent ($ resource ),
292
+ self ::EVENT_DATASTORE_DROPPED
293
+ );
294
+ }
288
295
}
289
296
290
297
if ($ remove_local_resource ) {
0 commit comments