aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2015-07-18 12:01:26 +0200
committerThomas Citharel <tcit@tcit.fr>2015-07-18 12:01:26 +0200
commit828d008bed8ef9abba047df16e5e09d8133bd3f3 (patch)
tree7e9fbc137fc4a4af70b05ce522ee37a61f445263 /inc
parentc129374147de3da613bf10124778ee59070d2a66 (diff)
downloadwallabag-828d008bed8ef9abba047df16e5e09d8133bd3f3.tar.gz
wallabag-828d008bed8ef9abba047df16e5e09d8133bd3f3.tar.zst
wallabag-828d008bed8ef9abba047df16e5e09d8133bd3f3.zip
fixed a postgresql-related bug, more database functions secured and add an exception for sqlite at installation
Diffstat (limited to 'inc')
-rwxr-xr-xinc/poche/Database.class.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 3b1f0af2..7ec1602d 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -454,20 +454,28 @@ class Database {
454 454
455 public function getPreviousArticle($id, $user_id) 455 public function getPreviousArticle($id, $user_id)
456 { 456 {
457 $sql = "SELECT id FROM entries WHERE id = (SELECT max(id) FROM entries WHERE id < ? AND is_read=0) AND user_id=? AND is_read=0"; 457 $sqlcondition = "is_read=0";
458 if (STORAGE == 'postgres') {
459 $sqlcondition = "is_read=false";
460 }
461 $sql = "SELECT id FROM entries WHERE id = (SELECT max(id) FROM entries WHERE id < ? AND " . $sqlcondition . ") AND user_id=? AND " . $sqlcondition;
458 $params = array($id, $user_id); 462 $params = array($id, $user_id);
459 $query = $this->executeQuery($sql, $params); 463 $query = $this->executeQuery($sql, $params);
460 $id_entry = $query->fetchAll(); 464 $id_entry = ($query) ? $query->fetchAll() : false;
461 $id = ($query) ? $id_entry[0][0] : false; 465 $id = ($query) ? $id_entry[0][0] : false;
462 return $id; 466 return $id;
463 } 467 }
464 468
465 public function getNextArticle($id, $user_id) 469 public function getNextArticle($id, $user_id)
466 { 470 {
467 $sql = "SELECT id FROM entries WHERE id = (SELECT min(id) FROM entries WHERE id > ? AND is_read=0) AND user_id=? AND is_read=0"; 471 $sqlcondition = "is_read=0";
472 if (STORAGE == 'postgres') {
473 $sqlcondition = "is_read=false";
474 }
475 $sql = "SELECT id FROM entries WHERE id = (SELECT min(id) FROM entries WHERE id > ? AND " . $sqlcondition . ") AND user_id=? AND " . $sqlcondition;
468 $params = array($id, $user_id); 476 $params = array($id, $user_id);
469 $query = $this->executeQuery($sql, $params); 477 $query = $this->executeQuery($sql, $params);
470 $id_entry = $query->fetchAll(); 478 $id_entry = ($query) ? $query->fetchAll() : false;
471 $id = ($query) ? $id_entry[0][0] : false; 479 $id = ($query) ? $id_entry[0][0] : false;
472 return $id; 480 return $id;
473 } 481 }