From a3d486408bf1ce30aa88223a75e2d7fa2da6bc0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 28 Aug 2015 19:17:04 +0200 Subject: [PATCH] Guard against stupid forum software containing duplicate subscriptions --- .../importer/AbstractWatchedObjectImporter.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/importer/AbstractWatchedObjectImporter.class.php b/wcfsetup/install/files/lib/system/importer/AbstractWatchedObjectImporter.class.php index 2b1ce6f44c..ff1c719aa7 100644 --- a/wcfsetup/install/files/lib/system/importer/AbstractWatchedObjectImporter.class.php +++ b/wcfsetup/install/files/lib/system/importer/AbstractWatchedObjectImporter.class.php @@ -1,6 +1,7 @@ getNewID('com.woltlab.wcf.user', $data['userID']); if (!$data['userID']) return 0; - $watch = UserObjectWatchEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID))); + try { + $watch = UserObjectWatchEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID))); + } + catch (DatabaseException $e) { + // 23000 = INTEGRITY CONSTRAINT VIOLATION a.k.a. duplicate key + if ($e->getCode() != 23000) { + throw $e; + } + } + return $watch->watchID; } } -- 2.20.1