From 22b41f3bfcbd5a54d59789c2cebfda6dc23b7dde Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 26 Mar 2017 00:01:11 +0100 Subject: Candidate implementation of defered insertion https://github.com/FreshRSS/FreshRSS/issues/530 --- app/Controllers/importExportController.php | 1 + 1 file changed, 1 insertion(+) (limited to 'app/Controllers/importExportController.php') diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 6ae89defb..ededfe506 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -475,6 +475,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } } $this->entryDAO->commit(); + $entryDAO->commitNewEntries(); return !$error; } -- cgit v1.2.3 From 7a6751b50d9c809d2127a154bf811f576a24e4a4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 26 Mar 2017 18:48:34 +0200 Subject: PDO fix PHP 7.1 http://php.net/manual/migration71.changed-functions.php#migration71.changed-functions.pdo --- app/Controllers/importExportController.php | 9 ++++----- app/Models/EntryDAO.php | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'app/Controllers/importExportController.php') diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 6ae89defb..af3c0bf46 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -464,15 +464,14 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } $values = $entry->toArray(); + $ok = false; if (isset($existingHashForGuids[$entry->guid()])) { - $id = $this->entryDAO->updateEntry($values); + $ok = $this->entryDAO->updateEntry($values); } else { - $id = $this->entryDAO->addEntry($values); + $ok = $this->entryDAO->addEntry($values); } + $error |= ($ok === false); - if (!$error && ($id === false)) { - $error = true; - } } $this->entryDAO->commit(); diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 0167695ca..96790c69c 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -152,7 +152,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { } if ($this->addEntryPrepared && $this->addEntryPrepared->execute()) { - return $this->bd->lastInsertId(); + return true; } else { $info = $this->addEntryPrepared == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $this->addEntryPrepared->errorInfo(); if ($this->autoUpdateDb($info)) { @@ -212,7 +212,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { } if ($this->updateEntryPrepared && $this->updateEntryPrepared->execute()) { - return $this->bd->lastInsertId(); + return true; } else { $info = $this->updateEntryPrepared == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $this->updateEntryPrepared->errorInfo(); if ($this->autoUpdateDb($info)) { -- cgit v1.2.3 From 5541e3951262bf93fc0eeb4938d6b93b01bfd1bd Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 27 Mar 2017 21:26:38 +0200 Subject: More defered insertion --- app/Controllers/feedController.php | 10 ++++++++-- app/Controllers/importExportController.php | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'app/Controllers/importExportController.php') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index bfc8b2045..5359ad198 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -321,6 +321,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { unset($newGuids); $oldGuids = array(); + $needFeedCacheRefresh = false; // Add entries in database if possible. foreach ($entries as $entry) { $entry_date = $entry->date(true); @@ -333,11 +334,12 @@ class FreshRSS_feed_Controller extends Minz_ActionController { //Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() . //', old hash ' . $existingHash . ', new hash ' . $entry->hash()); //TODO: Make an updated/is_read policy by feed, in addition to the global one. + $needFeedCacheRefresh = FreshRSS_Context::$user_conf->mark_updated_article_unread; $entry->_isRead(FreshRSS_Context::$user_conf->mark_updated_article_unread ? false : null); //Change is_read according to policy. if (!$entryDAO->inTransaction()) { $entryDAO->beginTransaction(); } - $entryDAO->updateEntry($entry->toArray()); + $entryDAO->updateEntry($entry->toArray()); //TODO: Need to refresh cache } } elseif ($feed_history == 0 && $entry_date < $date_min) { // This entry should not be added considering configuration and date. @@ -388,12 +390,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $date_min, max($feed_history, count($entries) + 10)); if ($nb > 0) { + $needFeedCacheRefresh = true; Minz_Log::debug($nb . ' old entries cleaned in feed [' . $feed->url() . ']'); } } $feedDAO->updateLastUpdate($feed->id(), false, $mtime); + if ($needFeedCacheRefresh) { + $feedDAO->updateCachedValue($feed->id()); + } if ($entryDAO->inTransaction()) { $entryDAO->commit(); } @@ -439,7 +445,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $entryDAO->beginTransaction(); } $entryDAO->commitNewEntries(); - $feedDAO->updateCachedValues(); //TODO: Optimize + $feedDAO->updateCachedValues(); if ($entryDAO->inTransaction()) { $entryDAO->commit(); } diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 82c49cc6a..2bc68848c 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -474,7 +474,11 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } $this->entryDAO->commit(); - $entryDAO->commitNewEntries(); + + $this->entryDAO->beginTransaction(); + $this->entryDAO->commitNewEntries(); + $this->feedDAO->updateCachedValues(); + $this->entryDAO->commit(); return !$error; } -- cgit v1.2.3