aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Frans de Jonge <fransdejonge@gmail.com> 2017-09-22 12:13:46 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-09-22 12:13:46 +0200
commit4e174ed9dd84ce4f8de410baf6a6e0fde9160055 (patch)
tree535a1ab9c37301e0b38527c7e86ce0b8bbef7b0a /app/Models
parent3ce2b4d1a8d70309ed353105b3fef617541a4b08 (diff)
[ci] Add Travis (#1619)
* [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/CategoryDAO.php10
-rw-r--r--app/Models/ConfigurationSetter.php10
-rw-r--r--app/Models/Context.php8
-rw-r--r--app/Models/DatabaseDAO.php2
-rw-r--r--app/Models/DatabaseDAOPGSQL.php2
-rw-r--r--app/Models/DatabaseDAOSQLite.php2
-rw-r--r--app/Models/Entry.php1
-rw-r--r--app/Models/EntryDAO.php100
-rw-r--r--app/Models/EntryDAOPGSQL.php2
-rw-r--r--app/Models/EntryDAOSQLite.php57
-rw-r--r--app/Models/Feed.php26
-rw-r--r--app/Models/FeedDAO.php20
-rw-r--r--app/Models/Share.php2
-rw-r--r--app/Models/Themes.php8
-rw-r--r--app/Models/UserDAO.php6
15 files changed, 161 insertions, 95 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index c2d57c241..f219c275f 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -2,7 +2,7 @@
class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
- const defaultCategoryId = 1;
+ const DEFAULTCATEGORYID = 1;
public function addCategory($valuesTmp) {
$sql = 'INSERT INTO `' . $this->prefix . 'category`(name) VALUES(?)';
@@ -53,7 +53,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable
}
public function deleteCategory($id) {
- if ($id <= self::defaultCategoryId) {
+ if ($id <= self::DEFAULTCATEGORYID) {
return false;
}
$sql = 'DELETE FROM `' . $this->prefix . 'category` WHERE id=?';
@@ -123,7 +123,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable
}
public function getDefault() {
- $sql = 'SELECT * FROM `' . $this->prefix . 'category` WHERE id=' . self::defaultCategoryId;
+ $sql = 'SELECT * FROM `' . $this->prefix . 'category` WHERE id=' . self::DEFAULTCATEGORYID;
$stm = $this->bd->prepare($sql);
$stm->execute();
@@ -137,11 +137,11 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable
}
}
public function checkDefault() {
- $def_cat = $this->searchById(self::defaultCategoryId);
+ $def_cat = $this->searchById(self::DEFAULTCATEGORYID);
if ($def_cat == null) {
$cat = new FreshRSS_Category(_t('gen.short.default_category'));
- $cat->_id(self::defaultCategoryId);
+ $cat->_id(self::DEFAULTCATEGORYID);
$values = array(
'id' => $cat->id(),
diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php
index 70e1dea2e..ca4709903 100644
--- a/app/Models/ConfigurationSetter.php
+++ b/app/Models/ConfigurationSetter.php
@@ -56,8 +56,7 @@ class FreshRSS_ConfigurationSetter {
switch ($value) {
case 'all':
$data['default_view'] = $value;
- $data['default_state'] = (FreshRSS_Entry::STATE_READ +
- FreshRSS_Entry::STATE_NOT_READ);
+ $data['default_state'] = (FreshRSS_Entry::STATE_READ + FreshRSS_Entry::STATE_NOT_READ);
break;
case 'adaptive':
case 'unread':
@@ -163,7 +162,7 @@ class FreshRSS_ConfigurationSetter {
if (!in_array($value, array('global', 'normal', 'reader'))) {
$value = 'normal';
}
- $data['view_mode'] = $value;
+ $data['view_mode'] = $value;
}
/**
@@ -326,7 +325,7 @@ class FreshRSS_ConfigurationSetter {
if (!in_array($value, array('silent', 'development', 'production'))) {
$value = 'production';
}
- $data['environment'] = $value;
+ $data['environment'] = $value;
}
private function _limits(&$data, $values) {
@@ -361,8 +360,7 @@ class FreshRSS_ConfigurationSetter {
$value = intval($value);
$limits = $limits_keys[$key];
- if (
- (!isset($limits['min']) || $value >= $limits['min']) &&
+ if ((!isset($limits['min']) || $value >= $limits['min']) &&
(!isset($limits['max']) || $value <= $limits['max'])
) {
$data['limits'][$key] = $value;
diff --git a/app/Models/Context.php b/app/Models/Context.php
index fd0e79fc1..2ca8f80b0 100644
--- a/app/Models/Context.php
+++ b/app/Models/Context.php
@@ -250,9 +250,7 @@ class FreshRSS_Context {
}
// If no feed have been found, next_get is the current category.
- self::$next_get = empty($another_unread_id) ?
- 'c_' . self::$current_get['category'] :
- 'f_' . $another_unread_id;
+ self::$next_get = empty($another_unread_id) ? 'c_' . self::$current_get['category'] : 'f_' . $another_unread_id;
break;
case 'c':
// We search the next category with at least one unread article.
@@ -275,9 +273,7 @@ class FreshRSS_Context {
}
// No unread category? The main stream will be our destination!
- self::$next_get = empty($another_unread_id) ?
- 'a' :
- 'c_' . $another_unread_id;
+ self::$next_get = empty($another_unread_id) ? 'a' : 'c_' . $another_unread_id;
break;
}
}
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php
index 0d85718e3..6ba5bca3e 100644
--- a/app/Models/DatabaseDAO.php
+++ b/app/Models/DatabaseDAO.php
@@ -9,7 +9,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {
$stm = $this->bd->prepare($sql);
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
-
+
$tables = array(
$this->prefix . 'category' => false,
$this->prefix . 'feed' => false,
diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php
index a4edaa448..2a18db970 100644
--- a/app/Models/DatabaseDAOPGSQL.php
+++ b/app/Models/DatabaseDAOPGSQL.php
@@ -12,7 +12,7 @@ class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAO {
$values = array($dbowner);
$stm->execute($values);
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
-
+
$tables = array(
$this->prefix . 'category' => false,
$this->prefix . 'feed' => false,
diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php
index 7f53f967d..2e1df132e 100644
--- a/app/Models/DatabaseDAOSQLite.php
+++ b/app/Models/DatabaseDAOSQLite.php
@@ -9,7 +9,7 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {
$stm = $this->bd->prepare($sql);
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
-
+
$tables = array(
'category' => false,
'feed' => false,
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 26cd24797..df3d59bea 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -189,6 +189,7 @@ class FreshRSS_Entry extends Minz_Model {
);
} catch (Exception $e) {
// rien à faire, on garde l'ancien contenu(requête a échoué)
+ Minz_Log::warning($e->getMessage());
}
}
}
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 7e836097a..bebafe500 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -146,13 +146,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
public function addEntry($valuesTmp) {
if ($this->addEntryPrepared == null) {
$sql = 'INSERT INTO `' . $this->prefix . 'entrytmp` (id, guid, title, author, '
- . ($this->isCompressed() ? 'content_bin' : 'content')
- . ', link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) '
- . 'VALUES(:id, :guid, :title, :author, '
- . ($this->isCompressed() ? 'COMPRESS(:content)' : ':content')
- . ', :link, :date, :last_seen, '
- . $this->sqlHexDecode(':hash')
- . ', :is_read, :is_favorite, :id_feed, :tags)';
+ . ($this->isCompressed() ? 'content_bin' : 'content')
+ . ', link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) '
+ . 'VALUES(:id, :guid, :title, :author, '
+ . ($this->isCompressed() ? 'COMPRESS(:content)' : ':content')
+ . ', :link, :date, :last_seen, '
+ . $this->sqlHexDecode(':hash')
+ . ', :is_read, :is_favorite, :id_feed, :tags)';
$this->addEntryPrepared = $this->bd->prepare($sql);
}
if ($this->addEntryPrepared) {
@@ -203,8 +203,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
public function commitNewEntries() {
$sql = 'SET @rank=(SELECT MAX(id) - COUNT(*) FROM `' . $this->prefix . 'entrytmp`); ' . //MySQL-specific
- 'INSERT IGNORE INTO `' . $this->prefix . 'entry` (id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) ' .
- 'SELECT @rank:=@rank+1 AS id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `' . $this->prefix . 'entrytmp` ORDER BY date; ' .
+ 'INSERT IGNORE INTO `' . $this->prefix . 'entry`
+ (
+ id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags
+ ) ' .
+ 'SELECT @rank:=@rank+1 AS id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags
+ FROM `' . $this->prefix . 'entrytmp`
+ ORDER BY date; ' .
'DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= @rank;';
$hadTransaction = $this->bd->inTransaction();
if (!$hadTransaction) {
@@ -226,13 +231,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
if ($this->updateEntryPrepared === null) {
$sql = 'UPDATE `' . $this->prefix . 'entry` '
- . 'SET title=:title, author=:author, '
- . ($this->isCompressed() ? 'content_bin=COMPRESS(:content)' : 'content=:content')
- . ', link=:link, date=:date, `lastSeen`=:last_seen, '
- . 'hash=' . $this->sqlHexDecode(':hash')
- . ', ' . ($valuesTmp['is_read'] === null ? '' : 'is_read=:is_read, ')
- . 'tags=:tags '
- . 'WHERE id_feed=:id_feed AND guid=:guid';
+ . 'SET title=:title, author=:author, '
+ . ($this->isCompressed() ? 'content_bin=COMPRESS(:content)' : 'content=:content')
+ . ', link=:link, date=:date, `lastSeen`=:last_seen, '
+ . 'hash=' . $this->sqlHexDecode(':hash')
+ . ', ' . ($valuesTmp['is_read'] === null ? '' : 'is_read=:is_read, ')
+ . 'tags=:tags '
+ . 'WHERE id_feed=:id_feed AND guid=:guid';
$this->updateEntryPrepared = $this->bd->prepare($sql);
}
@@ -295,8 +300,8 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
}
FreshRSS_UserDAO::touch();
$sql = 'UPDATE `' . $this->prefix . 'entry` '
- . 'SET is_favorite=? '
- . 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)';
+ . 'SET is_favorite=? '
+ . 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)';
$values = array($is_favorite ? 1 : 0);
$values = array_merge($values, $ids);
$stm = $this->bd->prepare($sql);
@@ -322,14 +327,14 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
*/
protected function updateCacheUnreads($catId = false, $feedId = false) {
$sql = 'UPDATE `' . $this->prefix . 'feed` f '
- . 'LEFT OUTER JOIN ('
- . 'SELECT e.id_feed, '
- . 'COUNT(*) AS nbUnreads '
- . 'FROM `' . $this->prefix . 'entry` e '
- . 'WHERE e.is_read=0 '
- . 'GROUP BY e.id_feed'
- . ') x ON x.id_feed=f.id '
- . 'SET f.`cache_nbUnreads`=COALESCE(x.nbUnreads, 0)';
+ . 'LEFT OUTER JOIN ('
+ . 'SELECT e.id_feed, '
+ . 'COUNT(*) AS nbUnreads '
+ . 'FROM `' . $this->prefix . 'entry` e '
+ . 'WHERE e.is_read=0 '
+ . 'GROUP BY e.id_feed'
+ . ') x ON x.id_feed=f.id '
+ . 'SET f.`cache_nbUnreads`=COALESCE(x.nbUnreads, 0)';
$hasWhere = false;
$values = array();
if ($feedId !== false) {
@@ -558,9 +563,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
public function searchByGuid($id_feed, $guid) {
// un guid est unique pour un flux donné
$sql = 'SELECT id, guid, title, author, '
- . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
- . ', link, date, is_read, is_favorite, id_feed, tags '
- . 'FROM `' . $this->prefix . 'entry` WHERE id_feed=? AND guid=?';
+ . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
+ . ', link, date, is_read, is_favorite, id_feed, tags '
+ . 'FROM `' . $this->prefix . 'entry` WHERE id_feed=? AND guid=?';
$stm = $this->bd->prepare($sql);
$values = array(
@@ -576,9 +581,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
public function searchById($id) {
$sql = 'SELECT id, guid, title, author, '
- . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
- . ', link, date, is_read, is_favorite, id_feed, tags '
- . 'FROM `' . $this->prefix . 'entry` WHERE id=?';
+ . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
+ . ', link, date, is_read, is_favorite, id_feed, tags '
+ . 'FROM `' . $this->prefix . 'entry` WHERE id=?';
$stm = $this->bd->prepare($sql);
$values = array($id);
@@ -600,16 +605,14 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
if (!($state & FreshRSS_Entry::STATE_READ)) {
$search .= 'AND ' . $alias . 'is_read=0 ';
}
- }
- elseif ($state & FreshRSS_Entry::STATE_READ) {
+ } elseif ($state & FreshRSS_Entry::STATE_READ) {
$search .= 'AND ' . $alias . 'is_read=1 ';
}
if ($state & FreshRSS_Entry::STATE_FAVORITE) {
if (!($state & FreshRSS_Entry::STATE_NOT_FAVORITE)) {
$search .= 'AND ' . $alias . 'is_favorite=1 ';
}
- }
- elseif ($state & FreshRSS_Entry::STATE_NOT_FAVORITE) {
+ } elseif ($state & FreshRSS_Entry::STATE_NOT_FAVORITE) {
$search .= 'AND ' . $alias . 'is_favorite=0 ';
}
@@ -621,7 +624,8 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
throw new FreshRSS_EntriesGetter_Exception('Bad order in Entry->listByType: [' . $order . ']!');
}
/*if ($firstId === '' && parent::$sharedDbType === 'mysql') {
- $firstId = $order === 'DESC' ? '9000000000'. '000000' : '0'; //MySQL optimization. TODO: check if this is needed again, after the filtering for old articles has been removed in 0.9-dev
+ //MySQL optimization. TODO: check if this is needed again, after the filtering for old articles has been removed in 0.9-dev
+ $firstId = $order === 'DESC' ? '9000000000'. '000000' : '0';
}*/
if ($firstId !== '') {
$search .= 'AND ' . $alias . 'id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' ';
@@ -759,13 +763,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min);
$sql = 'SELECT e0.id, e0.guid, e0.title, e0.author, '
- . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
- . ', e0.link, e0.date, e0.is_read, e0.is_favorite, e0.id_feed, e0.tags '
- . 'FROM `' . $this->prefix . 'entry` e0 '
- . 'INNER JOIN ('
- . $sql
- . ') e2 ON e2.id=e0.id '
- . 'ORDER BY e0.id ' . $order;
+ . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
+ . ', e0.link, e0.date, e0.is_read, e0.is_favorite, e0.id_feed, e0.tags '
+ . 'FROM `' . $this->prefix . 'entry` e0 '
+ . 'INNER JOIN ('
+ . $sql
+ . ') e2 ON e2.id=e0.id '
+ . 'ORDER BY e0.id ' . $order;
$stm = $this->bd->prepare($sql);
$stm->execute($values);
@@ -839,7 +843,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
public function countUnreadRead() {
$sql = 'SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id WHERE priority > 0'
- . ' UNION SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id WHERE priority > 0 AND is_read=0';
+ . ' UNION SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id WHERE priority > 0 AND is_read=0';
$stm = $this->bd->prepare($sql);
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
@@ -870,9 +874,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
public function countUnreadReadFavorites() {
$sql = 'SELECT c FROM ('
- . 'SELECT COUNT(id) AS c, 1 as o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 '
- . 'UNION SELECT COUNT(id) AS c, 2 AS o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 AND is_read=0'
- . ') u ORDER BY o';
+ . 'SELECT COUNT(id) AS c, 1 as o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 '
+ . 'UNION SELECT COUNT(id) AS c, 2 AS o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 AND is_read=0'
+ . ') u ORDER BY o';
$stm = $this->bd->prepare($sql);
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php
index 6e6f9e658..405774abf 100644
--- a/app/Models/EntryDAOPGSQL.php
+++ b/app/Models/EntryDAOPGSQL.php
@@ -11,7 +11,7 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite {
}
protected function autoUpdateDb($errorInfo) {
- if (isset($errorInfo[0])) {
+ if (isset($errorInfo[0])) {
if ($errorInfo[0] === '42P01' && stripos($errorInfo[2], 'entrytmp') !== false) { //undefined_table
return $this->createEntryTempTable();
}
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php
index ad7bcd865..8dad54322 100644
--- a/app/Models/EntryDAOSQLite.php
+++ b/app/Models/EntryDAOSQLite.php
@@ -27,11 +27,58 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
public function commitNewEntries() {
$sql = '
-CREATE TEMP TABLE `tmp` AS SELECT id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `' . $this->prefix . 'entrytmp` ORDER BY date;
-INSERT OR IGNORE INTO `' . $this->prefix . 'entry` (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags)
- SELECT rowid + (SELECT MAX(id) - COUNT(*) FROM `tmp`) AS id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `tmp` ORDER BY date;
-DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= (SELECT MAX(id) FROM `tmp`);
-DROP TABLE `tmp`;';
+ CREATE TEMP TABLE `tmp` AS
+ SELECT
+ id,
+ guid,
+ title,
+ author,
+ content,
+ link,
+ date,
+ `lastSeen`,
+ hash, is_read,
+ is_favorite,
+ id_feed,
+ tags
+ FROM `' . $this->prefix . 'entrytmp`
+ ORDER BY date;
+ INSERT OR IGNORE INTO `' . $this->prefix . 'entry`
+ (
+ id,
+ guid,
+ title,
+ author,
+ content,
+ link,
+ date,
+ `lastSeen`,
+ hash,
+ is_read,
+ is_favorite,
+ id_feed,
+ tags
+ )
+ SELECT rowid + (SELECT MAX(id) - COUNT(*) FROM `tmp`) AS
+ id,
+ guid,
+ title,
+ author,
+ content,
+ link,
+ date,
+ `lastSeen`,
+ hash,
+ is_read,
+ is_favorite,
+ id_feed,
+ tags
+ FROM `tmp`
+ ORDER BY date;
+ DELETE FROM `' . $this->prefix . 'entrytmp`
+ WHERE id <= (SELECT MAX(id)
+ FROM `tmp`);
+ DROP TABLE `tmp`;';
$hadTransaction = $this->bd->inTransaction();
if (!$hadTransaction) {
$this->bd->beginTransaction();
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 4f11d32e9..88ff9bf18 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -22,7 +22,7 @@ class FreshRSS_Feed extends Minz_Model {
private $hubUrl = '';
private $selfUrl = '';
- public function __construct($url, $validate=true) {
+ public function __construct($url, $validate = true) {
if ($validate) {
$this->_url($url);
} else {
@@ -165,7 +165,7 @@ class FreshRSS_Feed extends Minz_Model {
public function _id($value) {
$this->id = $value;
}
- public function _url($value, $validate=true) {
+ public function _url($value, $validate = true) {
$this->hash = null;
if ($validate) {
$value = checkUrl($value);
@@ -182,7 +182,7 @@ class FreshRSS_Feed extends Minz_Model {
public function _name($value) {
$this->name = $value === null ? '' : $value;
}
- public function _website($value, $validate=true) {
+ public function _website($value, $validate = true) {
if ($validate) {
$value = checkUrl($value);
}
@@ -254,7 +254,9 @@ class FreshRSS_Feed extends Minz_Model {
if ((!$mtime) || $feed->error()) {
$errorMessage = $feed->error();
- throw new FreshRSS_Feed_Exception(($errorMessage == '' ? 'Unknown error for feed' : $errorMessage) . ' [' . $url . ']');
+ throw new FreshRSS_Feed_Exception(
+ ($errorMessage == '' ? 'Unknown error for feed' : $errorMessage) . ' [' . $url . ']'
+ );
}
$links = $feed->get_links('self');
@@ -324,9 +326,11 @@ class FreshRSS_Feed extends Minz_Model {
if (strpos($mime, 'image/') === 0) {
$content .= '<p class="enclosure"><img src="' . $elink . '" alt="" /></p>';
} elseif (strpos($mime, 'audio/') === 0) {
- $content .= '<p class="enclosure"><audio preload="none" src="' . $elink . '" controls="controls"></audio> <a download="" href="' . $elink . '">💾</a></p>';
+ $content .= '<p class="enclosure"><audio preload="none" src="' . $elink
+ . '" controls="controls"></audio> <a download="" href="' . $elink . '">💾</a></p>';
} elseif (strpos($mime, 'video/') === 0) {
- $content .= '<p class="enclosure"><video preload="none" src="' . $elink . '" controls="controls"></video> <a download="" href="' . $elink . '">💾</a></p>';
+ $content .= '<p class="enclosure"><video preload="none" src="' . $elink
+ . '" controls="controls"></video> <a download="" href="' . $elink . '">💾</a></p>';
} elseif (strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) {
$content .= '<p class="enclosure"><a download="" href="' . $elink . '">💾</a></p>';
} else {
@@ -481,10 +485,12 @@ class FreshRSS_Feed extends Minz_Model {
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => 'FreshRSS/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ')',
- CURLOPT_POSTFIELDS => 'hub.verify=sync'
- . '&hub.mode=' . ($state ? 'subscribe' : 'unsubscribe')
- . '&hub.topic=' . urlencode($url)
- . '&hub.callback=' . urlencode($callbackUrl)
+ CURLOPT_POSTFIELDS => http_build_query(
+ 'hub.verify' => 'sync',
+ 'hub.mode' => ($state ? 'subscribe' : 'unsubscribe'),
+ 'hub.topic' => urlencode($url),
+ 'hub.callback' => urlencode($callbackUrl),
+ )
)
);
$response = curl_exec($ch);
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index d278122e3..0de6d98be 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -2,7 +2,23 @@
class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
public function addFeed($valuesTmp) {
- $sql = 'INSERT INTO `' . $this->prefix . 'feed` (url, category, name, website, description, `lastUpdate`, priority, `httpAuth`, error, keep_history, ttl) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)';
+ $sql = '
+ INSERT INTO `' . $this->prefix . 'feed`
+ (
+ url,
+ category,
+ name,
+ website,
+ description,
+ `lastUpdate`,
+ priority,
+ `httpAuth`,
+ error,
+ keep_history,
+ ttl
+ )
+ VALUES
+ (?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)';
$stm = $this->bd->prepare($sql);
$valuesTmp['url'] = safe_ascii($valuesTmp['url']);
@@ -380,7 +396,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
if ($catID === null) {
$category = isset($dao['category']) ? $dao['category'] : 0;
} else {
- $category = $catID ;
+ $category = $catID;
}
$myFeed = new FreshRSS_Feed(isset($dao['url']) ? $dao['url'] : '', false);
diff --git a/app/Models/Share.php b/app/Models/Share.php
index 1c8a7e767..86b1b9ed9 100644
--- a/app/Models/Share.php
+++ b/app/Models/Share.php
@@ -87,7 +87,7 @@ class FreshRSS_Share {
* decentralized ones.
* @param $help_url is an optional url to give help on this option.
*/
- private function __construct($type, $url_transform, $transform = array(),
+ private function __construct($type, $url_transform, $transform,
$form_type, $help_url = '') {
$this->type = $type;
$this->name = _t('gen.share.' . $type);
diff --git a/app/Models/Themes.php b/app/Models/Themes.php
index 5a6ec0a05..8920fbf7e 100644
--- a/app/Models/Themes.php
+++ b/app/Models/Themes.php
@@ -25,7 +25,7 @@ class FreshRSS_Themes extends Minz_Model {
}
public static function get_infos($theme_id) {
- $theme_dir = PUBLIC_PATH . self::$themesUrl . $theme_id ;
+ $theme_dir = PUBLIC_PATH . self::$themesUrl . $theme_id;
if (is_dir($theme_dir)) {
$json_filename = $theme_dir . '/metadata.json';
if (file_exists($json_filename)) {
@@ -109,10 +109,8 @@ class FreshRSS_Themes extends Minz_Model {
}
$url = $name . '.svg';
- $url = isset(self::$themeIcons[$url]) ? (self::$themeIconsUrl . $url) :
- (self::$defaultIconsUrl . $url);
+ $url = isset(self::$themeIcons[$url]) ? (self::$themeIconsUrl . $url) : (self::$defaultIconsUrl . $url);
- return $urlOnly ? Minz_Url::display($url) :
- '<img class="icon" src="' . Minz_Url::display($url) . '" alt="' . $alts[$name] . '" />';
+ return $urlOnly ? Minz_Url::display($url) : '<img class="icon" src="' . Minz_Url::display($url) . '" alt="' . $alts[$name] . '" />';
}
}
diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php
index 310c7c096..c921d54c9 100644
--- a/app/Models/UserDAO.php
+++ b/app/Models/UserDAO.php
@@ -83,17 +83,17 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {
}
public static function exist($username) {
- return is_dir(join_path(DATA_PATH , 'users', $username));
+ return is_dir(join_path(DATA_PATH, 'users', $username));
}
public static function touch($username = '') {
if (!FreshRSS_user_Controller::checkUsername($username)) {
$username = Minz_Session::param('currentUser', '_');
}
- return touch(join_path(DATA_PATH , 'users', $username, 'config.php'));
+ return touch(join_path(DATA_PATH, 'users', $username, 'config.php'));
}
public static function mtime($username) {
- return @filemtime(join_path(DATA_PATH , 'users', $username, 'config.php'));
+ return @filemtime(join_path(DATA_PATH, 'users', $username, 'config.php'));
}
}