Procházet zdrojové kódy

Fix SQL constraint insert into entrytmp table

https://github.com/FreshRSS/FreshRSS/issues/1614
Alexandre Alapetite před 8 roky
rodič
revize
28db5dd285

+ 6 - 1
app/Controllers/feedController.php

@@ -320,11 +320,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 				}
 				// For this feed, check existing GUIDs already in database.
 				$existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids);
-				unset($newGuids);
+				$newGuids = array();
 
 				$oldGuids = array();
 				// Add entries in database if possible.
 				foreach ($entries as $entry) {
+					if (isset($newGuids[$entry->guid()])) {
+						continue;	//Skip subsequent articles with same GUID
+					}
+					$newGuids[$entry->guid()] = true;
+
 					$entry_date = $entry->date(true);
 					if (isset($existingHashForGuids[$entry->guid()])) {
 						$existingHash = $existingHashForGuids[$entry->guid()];

+ 6 - 1
app/Controllers/importExportController.php

@@ -426,7 +426,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
 		}
 		// For this feed, check existing GUIDs already in database.
 		$existingHashForGuids = $this->entryDAO->listHashForFeedGuids($feed->id(), $newGuids);
-		unset($newGuids);
+		$newGuids = array();
 
 		// Then, articles are imported.
 		$this->entryDAO->beginTransaction();
@@ -455,6 +455,11 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
 			$entry->_id(min(time(), $entry->date(true)) . uSecString());
 			$entry->_tags($tags);
 
+			if (isset($newGuids[$entry->guid()])) {
+				continue;	//Skip subsequent articles with same GUID
+			}
+			$newGuids[$entry->guid()] = true;
+
 			$entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
 			if ($entry == null) {
 				// An extension has returned a null value, there is nothing to insert.