aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/feedController.php
diff options
context:
space:
mode:
authorGravatar Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> 2023-07-07 22:36:27 +0200
committerGravatar GitHub <noreply@github.com> 2023-07-07 22:36:27 +0200
commitf8f163d054110f7e0ff6650fca146b474335f4bd (patch)
treedbd831e600bc76ca2830cd417bd52b712ff97309 /app/Controllers/feedController.php
parent7f9594b8c7d7799f2e5f89328bd5981410db8cf0 (diff)
Chore/processing of depreciations and updating code to php72 minimum (#5504)
* processing of depreciations and updating of code to php7.2 minimum * Autoformat many strange array indenting And revert a few unwanted changes --------- Co-authored-by: Luc <sanchezluc+freshrss@gmail.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Controllers/feedController.php')
-rw-r--r--app/Controllers/feedController.php69
1 files changed, 36 insertions, 33 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 8c95a5c9c..e5685dddf 100644
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -54,7 +54,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$cat = $catDAO->searchById($cat_id);
}
if ($cat === null && $new_cat_name != '') {
- $new_cat_id = $catDAO->addCategory(array('name' => $new_cat_name));
+ $new_cat_id = $catDAO->addCategory(['name' => $new_cat_name]);
$cat_id = $new_cat_id > 0 ? $new_cat_id : $cat_id;
$cat = $catDAO->searchById($cat_id);
}
@@ -132,18 +132,18 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
if ($url === '') {
// No url, do nothing
- Minz_Request::forward(array(
+ Minz_Request::forward([
'c' => 'subscription',
- 'a' => 'index'
- ), true);
+ 'a' => 'index',
+ ], true);
}
$feedDAO = FreshRSS_Factory::createFeedDao();
- $url_redirect = array(
+ $url_redirect = [
'c' => 'subscription',
'a' => 'add',
- 'params' => array(),
- );
+ 'params' => [],
+ ];
$limits = FreshRSS_Context::$system_conf->limits;
$this->view->feeds = $feedDAO->listFeeds();
@@ -302,11 +302,11 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
*/
public function truncateAction(): void {
$id = Minz_Request::paramInt('id');
- $url_redirect = array(
+ $url_redirect = [
'c' => 'subscription',
'a' => 'index',
- 'params' => array('id' => $id)
- );
+ 'params' => ['id' => $id],
+ ];
if (!Minz_Request::isPost()) {
Minz_Request::forward($url_redirect, true);
@@ -337,7 +337,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
// Create a list of feeds to actualize.
// If feed_id is set and valid, corresponding feed is added to the list but
// alone in order to automatize further process.
- $feeds = array();
+ $feeds = [];
if ($feed_id > 0 || $feed_url) {
$feed = $feed_id > 0 ? $feedDAO->searchById($feed_id) : $feedDAO->searchByUrl($feed_url);
if ($feed) {
@@ -455,9 +455,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$titlesAsRead = array_flip($feedDAO->listTitles($feed->id(), (int)$readWhenSameTitleInFeed));
}
- $mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') !== null ? (
- $feed->attributes('mark_updated_article_unread')
- ) : FreshRSS_Context::$user_conf->mark_updated_article_unread;
+ $mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') ?? FreshRSS_Context::$user_conf->mark_updated_article_unread;
// For this feed, check existing GUIDs already in database.
$existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids) ?: [];
@@ -555,7 +553,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
unset($entries);
- if (mt_rand(0, 30) === 1) { // Remove old entries once in 30.
+ if (rand(0, 30) === 1) { // Remove old entries once in 30.
if (!$entryDAO->inTransaction()) {
$entryDAO->beginTransaction();
}
@@ -590,7 +588,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
$feed->_url($selfUrl, false);
Minz_Log::notice('Feed ' . $url . ' canonical address moved to ' . $feed->url(false));
- $feedDAO->updateFeed($feed->id(), array('url' => $feed->url()));
+ $feedDAO->updateFeed($feed->id(), ['url' => $feed->url()]);
}
}
} elseif ($feed->url() !== $url) { // HTTP 301 Moved Permanently
@@ -602,7 +600,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
if ($simplePie != null) {
if ($feed->name(true) === '') {
//HTML to HTML-PRE //ENT_COMPAT except '&'
- $name = strtr(html_only_entity_decode($simplePie->get_title()), array('<' => '&lt;', '>' => '&gt;', '"' => '&quot;'));
+ $name = strtr(html_only_entity_decode($simplePie->get_title()), ['<' => '&lt;', '>' => '&gt;', '"' => '&quot;']);
$feed->_name($name);
$feedProperties['name'] = $feed->name(false);
}
@@ -661,7 +659,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$databaseDAO = FreshRSS_Factory::createDatabaseDAO();
$databaseDAO->minorDbMaintenance();
}
- return array($updated_feeds, reset($feeds), $nb_new_articles);
+ return [$updated_feeds, reset($feeds), $nb_new_articles];
}
/**
@@ -722,13 +720,18 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
return $updated_feeds;
}
+ /**
+ * @throws Minz_ConfigurationNamespaceException
+ * @throws JsonException
+ * @throws Minz_PDOConnectionException
+ */
public static function renameFeed(int $feed_id, string $feed_name): bool {
if ($feed_id <= 0 || $feed_name === '') {
return false;
}
FreshRSS_UserDAO::touch();
$feedDAO = FreshRSS_Factory::createFeedDao();
- return $feedDAO->updateFeed($feed_id, array('name' => $feed_name)) === 1;
+ return $feedDAO->updateFeed($feed_id, ['name' => $feed_name]) === 1;
}
public static function moveFeed(int $feed_id, int $cat_id, string $new_cat_name = ''): bool {
@@ -743,7 +746,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$cat_id = $cat === null ? 0 : $cat->id();
}
if ($cat_id <= 1 && $new_cat_name != '') {
- $cat_id = $catDAO->addCategory(array('name' => $new_cat_name));
+ $cat_id = $catDAO->addCategory(['name' => $new_cat_name]);
}
if ($cat_id <= 1) {
$catDAO->checkDefault();
@@ -751,7 +754,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
$feedDAO = FreshRSS_Factory::createFeedDao();
- return $feedDAO->updateFeed($feed_id, array('category' => $cat_id)) === 1;
+ return $feedDAO->updateFeed($feed_id, ['category' => $cat_id]) === 1;
}
/**
@@ -768,7 +771,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
*/
public function moveAction(): void {
if (!Minz_Request::isPost()) {
- Minz_Request::forward(array('c' => 'subscription'), true);
+ Minz_Request::forward(['c' => 'subscription'], true);
}
$feed_id = Minz_Request::paramInt('f_id');
@@ -815,14 +818,14 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
switch ($from) {
case 'stats':
- $redirect_url = array('c' => 'stats', 'a' => 'idle');
+ $redirect_url = ['c' => 'stats', 'a' => 'idle'];
break;
case 'normal':
$get = Minz_Request::paramString('get');
if ($get) {
- $redirect_url = array('c' => 'index', 'a' => 'normal', 'params' => array('get' => $get));
+ $redirect_url = ['c' => 'index', 'a' => 'normal', 'params' => ['get' => $get]];
} else {
- $redirect_url = array('c' => 'index', 'a' => 'normal');
+ $redirect_url = ['c' => 'index', 'a' => 'normal'];
}
break;
default:
@@ -853,15 +856,15 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$feedDAO = FreshRSS_Factory::createFeedDao();
$feed = $feedDAO->searchById($id);
if ($feed === null) {
- Minz_Request::bad(_t('feedback.sub.feed.not_found'), array());
+ Minz_Request::bad(_t('feedback.sub.feed.not_found'), []);
return;
}
$feed->clearCache();
- Minz_Request::good(_t('feedback.sub.feed.cache_cleared', $feed->name()), array(
- 'params' => array('get' => 'f_' . $feed->id())
- ));
+ Minz_Request::good(_t('feedback.sub.feed.cache_cleared', $feed->name()), [
+ 'params' => ['get' => 'f_' . $feed->id()],
+ ]);
}
/**
@@ -884,7 +887,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$feed = $feedDAO->searchById($feed_id);
if ($feed === null) {
- Minz_Request::bad(_t('feedback.sub.feed.not_found'), array());
+ Minz_Request::bad(_t('feedback.sub.feed.not_found'), []);
return;
}
@@ -915,9 +918,9 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
Minz_ModelPdo::$usesSharedPdo = true;
//Give feedback to user.
- Minz_Request::good(_t('feedback.sub.feed.reloaded', $feed->name()), array(
- 'params' => array('get' => 'f_' . $feed->id())
- ));
+ Minz_Request::good(_t('feedback.sub.feed.reloaded', $feed->name()), [
+ 'params' => ['get' => 'f_' . $feed->id()]
+ ]);
}
/**