aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2018-01-02 23:53:35 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-01-02 23:53:35 +0100
commit7642d334f827d1c077bb1444dfc4e79acf022891 (patch)
tree904bb76cc119ff6d7a806cefd3c1fabbdebf2233 /app/Controllers
parente3ffc048d7a10a6116cf80fb6fceda0b4037368c (diff)
Replace "keep history" magic value by a constant (#1759)
I think the use of a magic value repeated many times in the code is prone to have some errors made by people not knowing its meaning. Using a constant is a bit more safe. Judging by some comments in the code, I am not the only one.
Diffstat (limited to 'app/Controllers')
-rwxr-xr-xapp/Controllers/entryController.php4
-rwxr-xr-xapp/Controllers/feedController.php6
-rw-r--r--app/Controllers/subscriptionController.php2
3 files changed, 4 insertions, 8 deletions
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php
index bd8b65b2b..9c6b248a9 100755
--- a/app/Controllers/entryController.php
+++ b/app/Controllers/entryController.php
@@ -177,9 +177,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController {
foreach ($feeds as $feed) {
$feed_history = $feed->keepHistory();
- if ($feed_history == -2) {
- // TODO: -2 must be a constant!
- // -2 means we take the default value from configuration
+ if (FreshRSS_Feed::KEEP_HISTORY_DEFAULT === $feed_history) {
$feed_history = FreshRSS_Context::$user_conf->keep_history_default;
}
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 2793577d5..884172112 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -317,10 +317,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feed_history = $feed->keepHistory();
if ($isNewFeed) {
- $feed_history = -1; //∞
- } elseif ($feed_history == -2) {
- // TODO: -2 must be a constant!
- // -2 means we take the default value from configuration
+ $feed_history = FreshRSS_Feed::KEEP_HISTORY_INFINITE;
+ } elseif (FreshRSS_Feed::KEEP_HISTORY_DEFAULT === $feed_history) {
$feed_history = FreshRSS_Context::$user_conf->keep_history_default;
}
$needFeedCacheRefresh = false;
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index b3f3df46e..37efd3b57 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -104,7 +104,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
'pathEntries' => Minz_Request::param('path_entries', ''),
'priority' => intval(Minz_Request::param('priority', FreshRSS_Feed::PRIORITY_MAIN_STREAM)),
'httpAuth' => $httpAuth,
- 'keep_history' => intval(Minz_Request::param('keep_history', -2)),
+ 'keep_history' => intval(Minz_Request::param('keep_history', FreshRSS_Feed::KEEP_HISTORY_DEFAULT)),
'ttl' => $ttl * ($mute ? -1 : 1),
);