mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-01 17:38:38 +00:00
fixed a postgresql-related bug, more database functions secured and add an exception for sqlite at installation
This commit is contained in:
parent
c129374147
commit
828d008bed
2 changed files with 20 additions and 8 deletions
|
@ -454,20 +454,28 @@ class Database {
|
||||||
|
|
||||||
public function getPreviousArticle($id, $user_id)
|
public function getPreviousArticle($id, $user_id)
|
||||||
{
|
{
|
||||||
$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";
|
$sqlcondition = "is_read=0";
|
||||||
|
if (STORAGE == 'postgres') {
|
||||||
|
$sqlcondition = "is_read=false";
|
||||||
|
}
|
||||||
|
$sql = "SELECT id FROM entries WHERE id = (SELECT max(id) FROM entries WHERE id < ? AND " . $sqlcondition . ") AND user_id=? AND " . $sqlcondition;
|
||||||
$params = array($id, $user_id);
|
$params = array($id, $user_id);
|
||||||
$query = $this->executeQuery($sql, $params);
|
$query = $this->executeQuery($sql, $params);
|
||||||
$id_entry = $query->fetchAll();
|
$id_entry = ($query) ? $query->fetchAll() : false;
|
||||||
$id = ($query) ? $id_entry[0][0] : false;
|
$id = ($query) ? $id_entry[0][0] : false;
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNextArticle($id, $user_id)
|
public function getNextArticle($id, $user_id)
|
||||||
{
|
{
|
||||||
$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";
|
$sqlcondition = "is_read=0";
|
||||||
|
if (STORAGE == 'postgres') {
|
||||||
|
$sqlcondition = "is_read=false";
|
||||||
|
}
|
||||||
|
$sql = "SELECT id FROM entries WHERE id = (SELECT min(id) FROM entries WHERE id > ? AND " . $sqlcondition . ") AND user_id=? AND " . $sqlcondition;
|
||||||
$params = array($id, $user_id);
|
$params = array($id, $user_id);
|
||||||
$query = $this->executeQuery($sql, $params);
|
$query = $this->executeQuery($sql, $params);
|
||||||
$id_entry = $query->fetchAll();
|
$id_entry = ($query) ? $query->fetchAll() : false;
|
||||||
$id = ($query) ? $id_entry[0][0] : false;
|
$id = ($query) ? $id_entry[0][0] : false;
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,10 +94,14 @@ else if (isset($_POST['install'])) {
|
||||||
$errors[] = 'Impossible to create the SQLite database file. Please check your file permissions.';
|
$errors[] = 'Impossible to create the SQLite database file. Please check your file permissions.';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite';
|
try {
|
||||||
$handle = new PDO($db_path);
|
$db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite';
|
||||||
$handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$handle = new PDO($db_path);
|
||||||
$sql_structure = "";
|
$handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$sql_structure = "";
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$errors[] = "SQLite has encountered an issue : " . $e->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// MySQL and Postgre
|
// MySQL and Postgre
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue