aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-01-26 21:17:16 +0100
committerGravatar GitHub <noreply@github.com> 2019-01-26 21:17:16 +0100
commit5b40920bb3fd30137adc3b9286dd62f2fb30ec5b (patch)
tree5840b608e7434e88b2b48f21bd071dd71db58c2d /app/Models
parent4872442c62f63ef97a0e12c43b4700b98ebcdc15 (diff)
parentef6df8aeca9f7b8dda96ab54fffd05f17b27606b (diff)
Merge pull request #2203 from FreshRSS/dev-1.14.0
Dev 1.14.0
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/EntryDAO.php2
-rw-r--r--app/Models/TagDAO.php34
2 files changed, 20 insertions, 16 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 08927196e..21f17c097 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -383,7 +383,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
*/
public function markRead($ids, $is_read = true) {
FreshRSS_UserDAO::touch();
- if (is_array($ids)) { //Many IDs at once (used by API)
+ if (is_array($ids)) { //Many IDs at once
if (count($ids) < 6) { //Speed heuristics
$affected = 0;
foreach ($ids as $id) {
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index dba854aa4..0b4428f17 100644
--- a/app/Models/TagDAO.php
+++ b/app/Models/TagDAO.php
@@ -256,9 +256,8 @@ class FreshRSS_TagDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
}
}
- //For API
- public function getEntryIdsTagNames($entries) {
- $sql = 'SELECT et.id_entry, t.name '
+ public function getTagsForEntries($entries) {
+ $sql = 'SELECT et.id_entry, et.id_tag, t.name '
. 'FROM `' . $this->prefix . 'tag` t '
. 'INNER JOIN `' . $this->prefix . 'entrytag` et ON et.id_tag = t.id';
@@ -282,26 +281,31 @@ class FreshRSS_TagDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
$stm = $this->bd->prepare($sql);
if ($stm && $stm->execute($values)) {
- $result = array();
- foreach ($stm->fetchAll(PDO::FETCH_ASSOC) as $line) {
- $entryId = 'e_' . $line['id_entry'];
- $tagName = $line['name'];
- if (empty($result[$entryId])) {
- $result[$entryId] = array();
- }
- $result[$entryId][] = $tagName;
- }
- return $result;
+ return $stm->fetchAll(PDO::FETCH_ASSOC);
} else {
$info = $stm == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
- return $this->getTagNamesEntryIds($id_entry);
+ return $this->getTagsForEntries($entries);
}
- Minz_Log::error('SQL error getTagNamesEntryIds: ' . $info[2]);
+ Minz_Log::error('SQL error getTagsForEntries: ' . $info[2]);
return false;
}
}
+ //For API
+ public function getEntryIdsTagNames($entries) {
+ $result = array();
+ foreach ($this->getTagsForEntries($entries) as $line) {
+ $entryId = 'e_' . $line['id_entry'];
+ $tagName = $line['name'];
+ if (empty($result[$entryId])) {
+ $result[$entryId] = array();
+ }
+ $result[$entryId][] = $tagName;
+ }
+ return $result;
+ }
+
public static function daoToTag($listDAO) {
$list = array();
if (!is_array($listDAO)) {