Last modified: 2009-07-14 20:49:07 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T21090, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 19090 - Watchlist settings of ApiEditPage are insufficient
Watchlist settings of ApiEditPage are insufficient
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Roan Kattouw
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-05 11:30 UTC by Amalthea
Modified: 2009-07-14 20:49 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Amalthea 2009-06-05 11:30:02 UTC
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.
Comment 1 Roan Kattouw 2009-06-05 15:52:08 UTC
(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.
Comment 2 Gurch 2009-06-06 09:37:36 UTC
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. :)
Comment 3 Amalthea 2009-06-07 21:22:05 UTC
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.
Comment 4 Amalthea 2009-07-04 20:17:52 UTC
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?
Comment 5 Roan Kattouw 2009-07-06 21:13:56 UTC
(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.
Comment 6 Bryan Tong Minh 2009-07-14 20:49:07 UTC
Fixed in r53266.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links