diff options
Diffstat (limited to 'classes/pref/feeds.php')
-rwxr-xr-x | classes/pref/feeds.php | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 03b70580b..a91d4b1e3 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -172,7 +172,7 @@ class Pref_Feeds extends Handler_Protected { if ($enable_cats) { array_push($root['items'], $cat); } else { - $root['items'] = array_merge($root['items'], $cat['items']); + array_push($root['items'], ...$cat['items']); } $sth = $this->pdo->prepare("SELECT * FROM @@ -202,7 +202,7 @@ class Pref_Feeds extends Handler_Protected { if ($enable_cats) { array_push($root['items'], $cat); } else { - $root['items'] = array_merge($root['items'], $cat['items']); + array_push($root['items'], ...$cat['items']); } } } @@ -373,7 +373,7 @@ class Pref_Feeds extends Handler_Protected { $order_id = 1; - $cat = $data_map[$item_id]; + $cat = ($data_map[$item_id] ?? false); if ($cat && is_array($cat)) { foreach ($cat as $item) { @@ -436,7 +436,7 @@ class Pref_Feeds extends Handler_Protected { foreach ($data['items'] as $item) { # if ($item['id'] != 'root') { - if (is_array($item['items'])) { + if (is_array($item['items'] ?? false)) { if (isset($item['items']['_reference'])) { $data_map[$item['id']] = array($item['items']); } else { @@ -454,14 +454,15 @@ class Pref_Feeds extends Handler_Protected { function removeIcon(): void { $feed_id = (int) $_REQUEST["feed_id"]; - $icon_file = Config::get(Config::ICONS_DIR) . "/$feed_id.ico"; + + $cache = DiskCache::instance('feed-icons'); $feed = ORM::for_table('ttrss_feeds') ->where('owner_uid', $_SESSION['uid']) ->find_one($feed_id); - if ($feed && file_exists($icon_file)) { - if (unlink($icon_file)) { + if ($feed && $cache->exists((string)$feed_id)) { + if ($cache->remove((string)$feed_id)) { $feed->set([ 'favicon_avg_color' => null, 'favicon_last_checked' => '1970-01-01', @@ -486,24 +487,25 @@ class Pref_Feeds extends Handler_Protected { if ($feed && $tmp_file && move_uploaded_file($_FILES['icon_file']['tmp_name'], $tmp_file)) { if (filesize($tmp_file) < Config::get(Config::MAX_FAVICON_FILE_SIZE)) { - $new_filename = Config::get(Config::ICONS_DIR) . "/$feed_id.ico"; - - if (file_exists($new_filename)) unlink($new_filename); - if (rename($tmp_file, $new_filename)) { - chmod($new_filename, 0644); + $cache = DiskCache::instance('feed-icons'); - $feed->set([ - 'favicon_avg_color' => null, - 'favicon_is_custom' => true, - ]); + if ($cache->put((string)$feed_id, file_get_contents($tmp_file))) { - if ($feed->save()) { - $rc = self::E_ICON_UPLOAD_SUCCESS; - } + $feed->set([ + 'favicon_avg_color' => null, + 'favicon_is_custom' => true, + ]); - } else { - $rc = self::E_ICON_RENAME_FAILED; + if ($feed->save()) { + $rc = self::E_ICON_UPLOAD_SUCCESS; } + + } else { + $rc = self::E_ICON_RENAME_FAILED; + } + + @unlink($tmp_file); + } else { $rc = self::E_ICON_FILE_TOO_LARGE; } @@ -512,7 +514,8 @@ class Pref_Feeds extends Handler_Protected { if (file_exists($tmp_file)) unlink($tmp_file); - print json_encode(['rc' => $rc, 'icon_url' => Feeds::_get_icon($feed_id)]); + print json_encode(['rc' => $rc, 'icon_url' => + Feeds::_get_icon($feed_id) . "?ts=" . time() ]); } function editfeed(): void { @@ -848,7 +851,7 @@ class Pref_Feeds extends Handler_Protected { if ($qpart) { $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids_qmarks) AND owner_uid = ?"); - $sth->execute(array_merge($feed_ids, [$_SESSION['uid']])); + $sth->execute([...$feed_ids, $_SESSION['uid']]); } } @@ -973,16 +976,6 @@ class Pref_Feeds extends Handler_Protected { persist="true" model="feedModel" openOnClick="false"> - <script type="dojo/method" event="onClick" args="item"> - var id = String(item.id); - var bare_id = id.substr(id.indexOf(':')+1); - - if (id.match('FEED:')) { - CommonDialogs.editFeed(bare_id); - } else if (id.match('CAT:')) { - dijit.byId('feedTree').editCategory(bare_id, item); - } - </script> </div> </div> </div> @@ -1161,6 +1154,7 @@ class Pref_Feeds extends Handler_Protected { ->select_many('id', 'title', 'feed_url', 'last_error', 'site_url') ->where_not_equal('last_error', '') ->where('owner_uid', $_SESSION['uid']) + ->where_gte('update_interval', 0) ->find_array()); } @@ -1196,9 +1190,10 @@ class Pref_Feeds extends Handler_Protected { $pdo->commit(); - if (file_exists(Config::get(Config::ICONS_DIR) . "/$id.ico")) { - unlink(Config::get(Config::ICONS_DIR) . "/$id.ico"); - } + $favicon_cache = DiskCache::instance('feed-icons'); + + if ($favicon_cache->exists((string)$id)) + $favicon_cache->remove((string)$id); } else { Labels::remove(Labels::feed_to_label_id($id), $owner_uid); |