Watchlist settings of ApiEditPage are insufficient
Closed, ResolvedPublic

Description

Author: Amalthea.wikimedia

Description:
Hello

What I want to achieve is that the watchlist setting of a page is simply left unchanged by an edit through ApiEditPage. This is a requirement for maintainance tools like [[WP:Twinkle]] and [[WP:Huggle]], and the parameters "watch" and "unwatch" offered by ApiEditPage are not sufficient for this.

The current code in ApiEditPage.php is:

if($params['watch'])
    $watch = true;
else if($params['unwatch'])
    $watch = false;
else if($titleObj->userIsWatching())
    $watch = true;
else if($wgUser->getOption('watchdefault'))
    $watch = true;
else if($wgUser->getOption('watchcreations') && !$titleObj->exists())
    $watch = true;
else
    $watch = false;

This code is acceptable if $wgUser->getOption('watchdefault') is turned off: I can set "watch" if the page should explicitly be watched, I can set "unwatch" if it should explicitly be unwatched. If I set nothing the watch status is unchanged.

If $wgUser->getOption('watchdefault') is true, many editors (like myself) do want to watchlist pages they edit manually, but not those edited through maintainance tools. However, with the above code, there is no way to leave the watch setting of a page as it is, short of getting the complete raw watchlist and setting "watch" or "unwatch" accordingly.

The best solution would be to offer a way that simply leaves the watchlist setting untouched. I can't see a clean solution short of introducing a third parameter for that, something like:

if($params['watch'])
    $watch = true;
else if($params['unwatch'])
    $watch = false;
else if ($params['watchunchanged'])
    $watch = $titleObj->userIsWatching();
else if($titleObj->userIsWatching())
    $watch = true;
else if($wgUser->getOption('watchdefault'))
    $watch = true;
else if($wgUser->getOption('watchcreations') && !$titleObj->exists())
    $watch = true;
else
    $watch = false;

The next best thing might be to provide a way to get the watchlist setting through ApiQueryInfo, but that obviously will necessitate many extra queries.


Version: unspecified
Severity: enhancement

bzimport added a project: MediaWiki-API.Via ConduitNov 21 2014, 10:42 PM
bzimport set Reference to bz19090.
bzimport created this task.Via LegacyJun 5 2009, 11:30 AM
Catrope added a comment.Via ConduitJun 5 2009, 3:52 PM

(In reply to comment #0)

The next best thing might be to provide a way to get the watchlist setting
through ApiQueryInfo, but that obviously will necessitate many extra queries.

I think that might be the best solution, since you're gonna be hitting prop=info for the edittoken and basetimestamp anyway.

bzimport added a comment.Via ConduitJun 6 2009, 9:37 AM

matthew.britton wrote:

Huggle currently loads the whole user watchlist to start with, so it is able to provide a "leave watchlist unchanged" option regardless of the user's watchlist preferences. This works reasonably well.

I personally think it would be a good idea to make API editing ignore the user's watchlist preferences completely; API clients don't need them. If they want to watch every page or creation they can pass "watch" with the request, the preference is only there so users don't have to check the "watch" check box every time they edit; bots don't get fed up like that. :)

bzimport added a comment.Via ConduitJun 7 2009, 9:22 PM

Amalthea.wikimedia wrote:

Roan, there are some cases where I already have a token and don't need a basetimestamp, e.g. when adding a notification to a user talk page via appendtext or section=new.

bzimport added a comment.Via ConduitJul 4 2009, 8:17 PM

Amalthea.wikimedia wrote:

Soo ... how can we go forward with this? I still think the cleanest solution would be to slightly enhance watchlist control offered by ApiEditPage. I believe this functionality does belong into ApiEditPage, and shouldn't really have to be replicated by getting the user's current watchlist setting and sending it back in.
I'm unsure why there are two parameters for watching and unwatching at the moment. Maybe the cleanest way would be to deprecate those, and replace them with one parameter instead, e.g.

watchlist=(watch|unwatch|preferences|nochange)

which will either forcibly watch, forcibly unwatch, decide upon preference settings (default), or leave the current watchlist setting untouched.

To me, this seems like a rather clean solution. If that's not an option, it would need to be a third parameter. If neither is acceptable though, and Gurch's way isn't either, what then? Do I need to prepare a patch for ApiQueryInfo to add an optional inprop to get the current watchlist setting?

Catrope added a comment.Via ConduitJul 6 2009, 9:13 PM

(In reply to comment #4)

I'm unsure why there are two parameters for watching and unwatching at the
moment. Maybe the cleanest way would be to deprecate those, and replace them
with one parameter instead, e.g.

watchlist=(watch|unwatch|preferences|nochange)

which will either forcibly watch, forcibly unwatch, decide upon preference
settings (default), or leave the current watchlist setting untouched.

That sounds like a good idea. I won't have much time to implement this soon, though.

bzimport added a comment.Via ConduitJul 14 2009, 8:49 PM

Bryan.TongMinh wrote:

Fixed in r53266.

Add Comment

Column Prototype
This is a very early prototype of a persistent column. It is not expected to work yet, and leaving it open will activate other new features which will break things. Press "\" (backslash) on your keyboard to close it now.