Преглед изворни кода

Fix entry_before_insert hook

The hook must be called also in:
- feedController->addAction()
- importExportController->importJson()

See https://github.com/FreshRSS/FreshRSS/issues/252
Marien Fressinaud пре 11 година
родитељ
комит
7ef4d6c033
2 измењених фајлова са 16 додато и 3 уклоњено
  1. 10 3
      app/Controllers/feedController.php
  2. 6 0
      app/Controllers/importExportController.php

+ 10 - 3
app/Controllers/feedController.php

@@ -174,10 +174,17 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 			$feedDAO->beginTransaction();
 			foreach ($entries as $entry) {
 				// Entries are added without any verification.
+				$entry->_feed($feed->id());
+				$entry->_id(min(time(), $entry->date(true)) . uSecString());
+				$entry->_isRead($is_read);
+
+				$entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
+				if (is_null($entry)) {
+					// An extension has returned a null value, there is nothing to insert.
+					continue;
+				}
+
 				$values = $entry->toArray();
-				$values['id_feed'] = $feed->id();
-				$values['id'] = min(time(), $entry->date(true)) . uSecString();
-				$values['is_read'] = $is_read;
 				$entryDAO->addEntry($values, $prepared_statement);
 			}
 			$feedDAO->updateLastUpdate($feed->id());

+ 6 - 0
app/Controllers/importExportController.php

@@ -385,6 +385,12 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
 			$entry->_id(min(time(), $entry->date(true)) . uSecString());
 			$entry->_tags($tags);
 
+			$entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
+			if (is_null($entry)) {
+				// An extension has returned a null value, there is nothing to insert.
+				continue;
+			}
+
 			$values = $entry->toArray();
 			$id = $this->entryDAO->addEntry($values, $prepared_statement);