Skip to content

Commit

Permalink
processing of depreciations and updating of code to php7.2 minimum
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc committed Jul 4, 2023
1 parent fc579bd commit ad98b9e
Show file tree
Hide file tree
Showing 41 changed files with 483 additions and 455 deletions.
17 changes: 10 additions & 7 deletions app/Controllers/authController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,26 @@ public function indexAction(): void {
*
* It forwards to the correct login page (form) or main page if
* the user is already connected.
* @throws Minz_ConfigurationParamException
*/
public function loginAction(): void {
if (FreshRSS_Auth::hasAccess() && Minz_Request::paramString('u') === '') {
Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true);
Minz_Request::forward(['c' => 'index', 'a' => 'index'], true);
}

$auth_type = FreshRSS_Context::$system_conf->auth_type;
FreshRSS_Context::initUser(Minz_User::INTERNAL_USER, false);
switch ($auth_type) {
case 'form':
Minz_Request::forward(array('c' => 'auth', 'a' => 'formLogin'));
Minz_Request::forward(['c' => 'auth', 'a' => 'formLogin']);
break;
case 'http_auth':
Minz_Error::error(403, array('error' => array(_t('feedback.access.denied'),
Minz_Error::error(403, [
'error' => [
_t('feedback.access.denied'),
' [HTTP Remote-User=' . htmlspecialchars(httpAuthUser(false), ENT_NOQUOTES, 'UTF-8') .
' ; Remote IP address=' . ($_SERVER['REMOTE_ADDR'] ?? '') . ']'
)), false);
' ; Remote IP address=' . ($_SERVER['REMOTE_ADDR'] ?? '') . ']']
], false);
break;
case 'none':
// It should not happen!
Expand Down Expand Up @@ -205,7 +208,7 @@ public function formLoginAction(): void {
Minz_Log::warning('Unsafe password mismatch for user ' . $username);
Minz_Request::bad(
_t('feedback.auth.login.invalid'),
array('c' => 'auth', 'a' => 'login')
['c' => 'auth', 'a' => 'login']
);
}
}
Expand All @@ -229,7 +232,7 @@ public function logoutAction(): void {
*/
public function registerAction(): void {
if (FreshRSS_Auth::hasAccess()) {
Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true);
Minz_Request::forward(['c' => 'index', 'a' => 'index'], true);
}

if (max_registrations_reached()) {
Expand Down
10 changes: 5 additions & 5 deletions app/Controllers/categoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function createAction() :void {
$catDAO = FreshRSS_Factory::createCategoryDao();
$tagDAO = FreshRSS_Factory::createTagDao();

$url_redirect = array('c' => 'subscription', 'a' => 'add');
$url_redirect = ['c' => 'subscription', 'a' => 'add'];

$limits = FreshRSS_Context::$system_conf->limits;
$this->view->categories = $catDAO->listCategories(false) ?: [];
Expand Down Expand Up @@ -88,7 +88,7 @@ public function createAction() :void {
*/
public function updateAction(): void {
$catDAO = FreshRSS_Factory::createCategoryDao();
$url_redirect = array('c' => 'subscription', 'a' => 'index');
$url_redirect = ['c' => 'subscription', 'a' => 'index'];

if (Minz_Request::isPost()) {
invalidateHttpCache();
Expand Down Expand Up @@ -131,7 +131,7 @@ public function updateAction(): void {
public function deleteAction(): void {
$feedDAO = FreshRSS_Factory::createFeedDao();
$catDAO = FreshRSS_Factory::createCategoryDao();
$url_redirect = array('c' => 'subscription', 'a' => 'index');
$url_redirect = ['c' => 'subscription', 'a' => 'index'];

if (Minz_Request::isPost()) {
invalidateHttpCache();
Expand Down Expand Up @@ -174,7 +174,7 @@ public function deleteAction(): void {
*/
public function emptyAction(): void {
$feedDAO = FreshRSS_Factory::createFeedDao();
$url_redirect = array('c' => 'subscription', 'a' => 'index');
$url_redirect = ['c' => 'subscription', 'a' => 'index'];

if (Minz_Request::isPost()) {
invalidateHttpCache();
Expand Down Expand Up @@ -214,7 +214,7 @@ public function emptyAction(): void {
*/
public function refreshOpmlAction(): void {
$catDAO = FreshRSS_Factory::createCategoryDao();
$url_redirect = array('c' => 'subscription', 'a' => 'index');
$url_redirect = ['c' => 'subscription', 'a' => 'index'];

if (Minz_Request::isPost()) {
invalidateHttpCache();
Expand Down
16 changes: 8 additions & 8 deletions app/Controllers/configureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ public function readingAction(): void {
FreshRSS_Context::$user_conf->auto_remove_article = Minz_Request::paramBoolean('auto_remove_article');
FreshRSS_Context::$user_conf->mark_updated_article_unread = Minz_Request::paramBoolean('mark_updated_article_unread');
FreshRSS_Context::$user_conf->sort_order = Minz_Request::paramString('sort_order') ?: 'DESC';
FreshRSS_Context::$user_conf->mark_when = array(
FreshRSS_Context::$user_conf->mark_when = [
'article' => Minz_Request::paramBoolean('mark_open_article'),
'gone' => Minz_Request::paramBoolean('read_upon_gone'),
'max_n_unread' => Minz_Request::paramBoolean('enable_keep_max_n_unread') ? Minz_Request::paramInt('keep_max_n_unread') : false,
'reception' => Minz_Request::paramBoolean('mark_upon_reception'),
'same_title_in_feed' => Minz_Request::paramBoolean('enable_read_when_same_title_in_feed') ?
Minz_Request::paramBoolean('read_when_same_title_in_feed') : false,
'same_title_in_feed' =>
Minz_Request::paramBoolean('enable_read_when_same_title_in_feed') && Minz_Request::paramBoolean('read_when_same_title_in_feed'),
'scroll' => Minz_Request::paramBoolean('mark_scroll'),
'site' => Minz_Request::paramBoolean('mark_open_site'),
);
];
FreshRSS_Context::$user_conf->save();
invalidateHttpCache();

Expand Down Expand Up @@ -197,7 +197,7 @@ public function shortcutAction(): void {
FreshRSS_Context::$user_conf->save();
invalidateHttpCache();

Minz_Request::good(_t('feedback.conf.shortcuts_updated'), array('c' => 'configure', 'a' => 'shortcut'));
Minz_Request::good(_t('feedback.conf.shortcuts_updated'), ['c' => 'configure', 'a' => 'shortcut']);
}

FreshRSS_View::prependTitle(_t('conf.shortcut.title') . ' · ');
Expand Down Expand Up @@ -313,7 +313,7 @@ public function queriesAction(): void {

Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'queries' ]);
} else {
$this->view->queries = array();
$this->view->queries = [];
foreach (FreshRSS_Context::$user_conf->queries as $key => $query) {
$this->view->queries[intval($key)] = new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao);
}
Expand Down Expand Up @@ -419,13 +419,13 @@ public function bookmarkQueryAction(): void {
$category_dao = FreshRSS_Factory::createCategoryDao();
$feed_dao = FreshRSS_Factory::createFeedDao();
$tag_dao = FreshRSS_Factory::createTagDao();
$queries = array();
$queries = [];
foreach (FreshRSS_Context::$user_conf->queries as $key => $query) {
$queries[$key] = (new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao))->toArray();
}
$params = $_GET;
unset($params['rid']);
$params['url'] = Minz_Url::display(array('params' => $params));
$params['url'] = Minz_Url::display(['params' => $params]);
$params['name'] = _t('conf.query.number', count($queries) + 1);
$queries[] = (new FreshRSS_UserQuery($params, $feed_dao, $category_dao, $tag_dao))->toArray();

Expand Down
31 changes: 16 additions & 15 deletions app/Controllers/entryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function readAction(): void {
if ($id == false) {
// id is false? It MUST be a POST request!
if (!Minz_Request::isPost()) {
Minz_Request::bad(_t('feedback.access.not_found'), array('c' => 'index', 'a' => 'index'));
Minz_Request::bad(_t('feedback.access.not_found'), ['c' => 'index', 'a' => 'index']);
return;
}

Expand Down Expand Up @@ -104,11 +104,11 @@ public function readAction(): void {
}
}
} else {
$ids = is_array($id) ? $id : array($id);
$ids = is_array($id) ? $id : [$id];
$entryDAO->markRead($ids, $is_read);
$tagDAO = FreshRSS_Factory::createTagDao();
$tagsForEntries = $tagDAO->getTagsForEntries($ids) ?: [];
$tags = array();
$tags = [];
foreach ($tagsForEntries as $line) {
$tags['t_' . $line['id_tag']][] = $line['id_entry'];
}
Expand All @@ -117,11 +117,12 @@ public function readAction(): void {

if (!$this->ajax) {
Minz_Request::good($is_read ? _t('feedback.sub.articles.marked_read') : _t('feedback.sub.articles.marked_unread'),
array(
'c' => 'index',
'a' => 'index',
'params' => $params,
));
[
'c' => 'index',
'a' => 'index',
'params' => $params,
]
);
}
}

Expand All @@ -142,10 +143,10 @@ public function bookmarkAction(): void {
}

if (!$this->ajax) {
Minz_Request::forward(array(
Minz_Request::forward([
'c' => 'index',
'a' => 'index',
), true);
], true);
}
}

Expand All @@ -158,10 +159,10 @@ public function bookmarkAction(): void {
* @todo call this action through web-cron when available
*/
public function optimizeAction(): void {
$url_redirect = array(
$url_redirect = [
'c' => 'configure',
'a' => 'archiving',
);
];

if (!Minz_Request::isPost()) {
Minz_Request::forward($url_redirect, true);
Expand Down Expand Up @@ -207,9 +208,9 @@ public function purgeAction(): void {
$databaseDAO->minorDbMaintenance();

invalidateHttpCache();
Minz_Request::good(_t('feedback.sub.purge_completed', $nb_total), array(
Minz_Request::good(_t('feedback.sub.purge_completed', $nb_total), [
'c' => 'configure',
'a' => 'archiving'
));
'a' => 'archiving',
]);
}
}
2 changes: 1 addition & 1 deletion app/Controllers/errorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FreshRSS_error_Controller extends FreshRSS_ActionController {
*/
public function indexAction(): void {
$code_int = Minz_Session::param('error_code', 404);
$error_logs = Minz_Session::param('error_logs', array());
$error_logs = Minz_Session::param('error_logs', []);
Minz_Session::_params([
'error_code' => false,
'error_logs' => false,
Expand Down
24 changes: 12 additions & 12 deletions app/Controllers/extensionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public function firstAction(): void {
*/
public function indexAction(): void {
FreshRSS_View::prependTitle(_t('admin.extensions.title') . ' · ');
$this->view->extension_list = array(
'system' => array(),
'user' => array(),
);
$this->view->extension_list = [
'system' => [],
'user' => [],
];

$this->view->extensions_installed = array();
$this->view->extensions_installed = [];

$extensions = Minz_ExtensionManager::listExtensions();
foreach ($extensions as $ext) {
Expand All @@ -47,21 +47,21 @@ protected function getAvailableExtensionList(): array {
// we ran into problems, simply ignore them
if ($json === false) {
Minz_Log::error('Could not fetch available extension from GitHub');
return array();
return [];
}

// fetch the list as an array
/** @var array<string,mixed> */
/** @var array<string,mixed> $list*/
$list = json_decode($json, true);
if (empty($list)) {
Minz_Log::warning('Failed to convert extension file list');
return array();
return [];
}

// By now, all the needed data is kept in the main extension file.
// In the future we could fetch detail information from the extensions metadata.json, but I tend to stick with
// the current implementation for now, unless it becomes too much effort maintain the extension list manually
/** @var array<string,array{'name':string,'author':string,'description':string,'version':string,'entrypoint':string,'type':'system'|'user','url':string,'method':string,'directory':string}> */
/** @var array<string,array{'name':string,'author':string,'description':string,'version':string,'entrypoint':string,'type':'system'|'user','url':string,'method':string,'directory':string}> $extensions*/
$extensions = $list['extensions'];

return $extensions;
Expand Down Expand Up @@ -112,7 +112,7 @@ public function configureAction(): void {
* - e: the extension name (urlencoded).
*/
public function enableAction(): void {
$url_redirect = array('c' => 'extension', 'a' => 'index');
$url_redirect = ['c' => 'extension', 'a' => 'index'];

if (Minz_Request::isPost()) {
$ext_name = urldecode(Minz_Request::paramString('e'));
Expand Down Expand Up @@ -174,7 +174,7 @@ public function enableAction(): void {
* - e: the extension name (urlencoded).
*/
public function disableAction(): void {
$url_redirect = array('c' => 'extension', 'a' => 'index');
$url_redirect = ['c' => 'extension', 'a' => 'index'];

if (Minz_Request::isPost()) {
$ext_name = urldecode(Minz_Request::paramString('e'));
Expand Down Expand Up @@ -240,7 +240,7 @@ public function removeAction(): void {
Minz_Error::error(403);
}

$url_redirect = array('c' => 'extension', 'a' => 'index');
$url_redirect = ['c' => 'extension', 'a' => 'index'];

if (Minz_Request::isPost()) {
$ext_name = urldecode(Minz_Request::paramString('e'));
Expand Down

0 comments on commit ad98b9e

Please sign in to comment.