Page MenuHomePhabricator

Maximum to "Days to show in watchlist" in preferences should equal $wgRCMaxAge
Closed, ResolvedPublic

Description

Author: wolkwitz

Description:
It's not possible to enter and save a number larger than 7 for User preferences / recent changes / Days to show in recent changes. If one tries the entry reverts to 7 after pressing the save button.

I believe it's because of this line:

$wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1, 7 ) );

in http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/SpecialPreferences.php?view=markup

The value should be increased (at least up to 30 in order to reflect the possibilities in Special:Recentchanges), and/or the message [[MediaWiki:Recentchangesdays]] could be changed to reflect the restricted range of choices.

If only certain numbers are to be allowed (as in Special:Recentchanges), it should be changed to a drop-down box rather than a write-in field.


Version: 1.18.x
Severity: normal

Details

Reference
bz11612

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:56 PM
bzimport set Reference to bz11612.
bzimport added a subscriber: Unknown Object (MLST).

This has a reason: the recentchanges table doesn't log every single edit since the beginning of time, but only those in the last 7 days. Older edits are removed from the table on a regular basis. But of course, an rc lifetime larger than 7 days should be allowed for low-traffic wikis.

brianna.laugher wrote:

(In reply to comment #1)

This has a reason: the recentchanges table doesn't log every single edit since
the beginning of time, but only those in the last 7 days. Older edits are
removed from the table on a regular basis. But of course, an rc lifetime larger
than 7 days should be allowed for low-traffic wikis.

But on Special:Recentchanges you can choose up to 30 days. Even on en.wp. Is that a mistake?

(In reply to comment #2)

But on Special:Recentchanges you can choose up to 30 days. Even on en.wp. Is
that a mistake?

My mistake. At Wikipedia and friends $wgRCMaxAge is set to 30 days, and the default value is 7 days. This means the line of code you quoted should probably be

$wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1, ceil($wgRCMaxAge / (3600*24))));

$wgRCMaxAge should be 7 for WMF sites. I though domas changed that.

(In reply to comment #4)

$wgRCMaxAge should be 7 for WMF sites. I though domas changed that.

Whatever it is, the point is that $wgRCMaxAge is customizable and therefore the 7 in SpecialPreferences.php shouldn't be hardcoded.

wolkwitz wrote:

(In reply to comment #3)

(In reply to comment #2)

But on Special:Recentchanges you can choose up to 30 days. Even on en.wp. Is
that a mistake?

My mistake. At Wikipedia and friends $wgRCMaxAge is set to 30 days, and the
default value is 7 days. This means the line of code you quoted should probably
be

$wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1,
ceil($wgRCMaxAge / (3600*24))));

I've tried this and found that with it, the number of days is alway set to 1 - even though I've set
$wgRCMaxAge = 100 * 24 * 3600;
in my LocalSettings.php

Using the line
$wgUser->setOption( 'rcdays', $this->validateInt( $this->mRecentDays, 1, 100 ) );
instead allows me to set the number of days to 30.

Is there an error somewhere in your code?

(In reply to comment #6)

I've tried this and found that with it, the number of days is alway set to 1 -
even though I've set
$wgRCMaxAge = 100 * 24 * 3600;
in my LocalSettings.php

Using the line
$wgUser->setOption( 'rcdays', $this->validateInt( $this->mRecentDays, 1, 100 )
);
instead allows me to set the number of days to 30.

Is there an error somewhere in your code?

Yes, this is a bug. The 7 in the "$this->mRecentDays, 1, 7" part should be calculated based on $wgRCMaxAge.

wolkwitz wrote:

(In reply to comment #7)

(In reply to comment #6)

I've tried this and found that with it, the number of days is alway set to 1 -
even though I've set
$wgRCMaxAge = 100 * 24 * 3600;
in my LocalSettings.php

Using the line
$wgUser->setOption( 'rcdays', $this->validateInt( $this->mRecentDays, 1, 100 )
);
instead allows me to set the number of days to 30.

Is there an error somewhere in your code?

Yes, this is a bug. The 7 in the "$this->mRecentDays, 1, 7" part should be
calculated based on $wgRCMaxAge.

I understand and support that idea, but somehow using a parameter like $wgRCMaxAge in the line, like your example

$wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1, ceil($wgRCMaxAge / (3600*24))));

doesn't work. I think the problem lies with the use of a parameter, because I tried setting a new parameter
$wgMyRCdays = 100; in LocalSettings.php and then using the following line:

$wgUser->setOption( 'rcdays', $this->validateInt( $this->mRecentDays, 1, $wgMyRCdays ) );

But that got the same result: the number of days is always reset to 1. :(

I understand and support that idea, but somehow using a parameter like
$wgRCMaxAge in the line, like your example

$wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1,
ceil($wgRCMaxAge / (3600*24))));

doesn't work. I think the problem lies with the use of a parameter, because I
tried setting a new parameter
$wgMyRCdays = 100; in LocalSettings.php and then using the following line:

$wgUser->setOption( 'rcdays', $this->validateInt( $this->mRecentDays, 1,
$wgMyRCdays ) );

But that got the same result: the number of days is always reset to 1. :(

I forgot you have to insert the following line right before the modified line:

global $wgRCMaxAge;

For your $wgMyRCDays thingy to work, you would need:

global $wgMyRCDays;

wolkwitz wrote:

(In reply to comment #9)

I understand and support that idea, but somehow using a parameter like
$wgRCMaxAge in the line, like your example

$wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1,
ceil($wgRCMaxAge / (3600*24))));

doesn't work. I think the problem lies with the use of a parameter, because I
tried setting a new parameter
$wgMyRCdays = 100; in LocalSettings.php and then using the following line:

$wgUser->setOption( 'rcdays', $this->validateInt( $this->mRecentDays, 1,
$wgMyRCdays ) );

But that got the same result: the number of days is always reset to 1. :(

I forgot you have to insert the following line right before the modified line:

global $wgRCMaxAge;

For your $wgMyRCDays thingy to work, you would need:

global $wgMyRCDays;

Thanks - now it works based on the $wgRCMaxAge-value set in LocalSettings.php :-)

(In reply to comment #10)

Thanks - now it works based on the $wgRCMaxAge-value set in LocalSettings.php
:-)

Good. I've fixed this on trunk in r26591, which means future versions of MediaWiki will no longer have this bug.

On sites with multiple wikis, especially ones with low traffic, it should be possible to set your preferences to show days in recent changes greater than 30s if $wgRCMaxAge allows it.

Clarified summary. The problem is still there: in any WMF wiki I've checked, "Days to show in watchlist" in the preferences is said to be "Maximum 7 days" (and it actually works, n > 7 can't be saved).

Because of bug 26022 you can't know from the interface what the actual maximum is (unless you have enough pages in watchlist and you ask "all days") and it can change, so I've always just put 0 in the wikis where I want to see everything, but it's not very user-friendly for the newbies who don't know the trick.

General rationale: there's no reason why the preferences for a special page should be allowed to remember only the values suggested by the GUI of the special page itself; "adding" values 7 < n ≤ $wgRCMaxAge in the preferences doesn't clutter the interface. Compare bug 31881 which could reduce flexibility or require too much clutter in the special pages (where it harms more than in the preferences).

  • Bug 32315 has been marked as a duplicate of this bug. ***