summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2020-05-21 20:55:06 +0200
committerGravatar GitHub <noreply@github.com> 2020-05-21 20:55:06 +0200
commit857f58879022e7ab8dcc30380ee00df5277b8c0c (patch)
treea0e245f96d10261104e15bb0b0a0f78d615e2b7c
parentdf9d3ab468602da384edccfcadc55ada96ebfdd9 (diff)
Fix fetch preview (#2993)
* Fix fetch preview #fix https://github.com/FreshRSS/FreshRSS/issues/2923 In MariaDB / MySQL, we cannot start a new query if we have not consumed the previous buffered query fully. * Fix for reload * Typo in comment
-rwxr-xr-xapp/Controllers/feedController.php13
-rw-r--r--app/Models/FeedDAO.php8
2 files changed, 11 insertions, 10 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index b8ccaf963..4750f4558 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -700,14 +700,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
//Extract all feed entries from database, load complete content and store them back in database.
$entries = $entryDAO->listWhere('f', $feed_id, FreshRSS_Entry::STATE_ALL, 'DESC', 0);
- $entryDAO->beginTransaction();
+ //We need another DB connection in parallel
+ Minz_ModelPdo::$usesSharedPdo = false;
+ $entryDAO2 = FreshRSS_Factory::createEntryDao();
foreach ($entries as $entry) {
$entry->loadCompleteContent(true);
- $entryDAO->updateEntry($entry->toArray());
+ $entryDAO2->updateEntry($entry->toArray());
}
- $entryDAO->commit();
+ Minz_ModelPdo::$usesSharedPdo = true;
//Give feedback to user.
Minz_Request::good(_t('feedback.sub.feed.reloaded', $feed->name()), array(
@@ -755,8 +757,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
//Get first entry (syntax robust for Generator or Array)
foreach ($entries as $myEntry) {
- $entry = $myEntry;
- break;
+ if ($entry == null) {
+ $entry = $myEntry;
+ }
}
if ($entry == null) {
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index 11db5e3d4..6f675ead0 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -258,12 +258,10 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
}
public function searchById($id) {
- $sql = 'SELECT * FROM `_feed` WHERE id=?';
+ $sql = 'SELECT * FROM `_feed` WHERE id=:id';
$stm = $this->pdo->prepare($sql);
-
- $values = array($id);
-
- $stm->execute($values);
+ $stm->bindParam(':id', $id, PDO::PARAM_INT);
+ $stm->execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
$feed = self::daoToFeed($res);