Last modified: 2011-12-27 01:23:20 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 T29146, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 27146 - mw.action.watch.ajax should work $wgActionPaths is configured for watch/unwatch
mw.action.watch.ajax should work $wgActionPaths is configured for watch/unwatch
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
1.18.x
All All
: Normal normal (vote)
: ---
Assigned To: Krinkle
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-03 23:26 UTC by Brion Vibber
Modified: 2011-12-27 01:23 UTC (History)
4 users (show)

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


Attachments

Description Brion Vibber 2011-02-03 23:26:11 UTC
Tested as of r81491; relevant bit of code was last touched in r78150.

When initializing the AJAX behavior for the watch tab, it seems that current code tries to divine the target page title from the link URL on the watch tab, then save that title as extra data associated with the link node:

in mediawiki.action.watch.ajax.js:

		var title = mw.util.getParamValue( 'title', link.href );
		$link.data( 'target', title.replace( /_/g, ' ' ) );

This unfortunately fails when the target link doesn't use a query string parameter -- mw.util.getParamValue() is unable to find it, and the next line throws an error:

    title is null
    [Break On This Error] $link.data('target',title.replace(/_/g,' '));

As a result, AJAX watch fails to initialize properly, and the unhandled exception may also halt initialization of other UI elements.


This code probably doesn't need to be trying to pull a title from the link manually; it should probably just be using the available wgTitle.


Steps to reproduce:

1) Set some items in $wgActionPaths, say:

  $actions = array('watch', 'unwatch');
  foreach ($actions as $a)  {
         $wgActionPaths[$a] = "$wgScriptPath/action/$a/$1";
  }

2) Set up appropriate rewrite rules or helper scripts to pass /action/(un)?watch/Foo over to /index.php?action=blah&title=Foo

3) Load up a page view while logged in.
Comment 1 Krinkle 2011-02-07 13:24:42 UTC
Assigning to me as I should've fixed this when rewriting this.

I remember thinking about this but I didn't actually write it down nor fix it.
Although I didn't introduce the bug, I'll finish this up this afternoon.


+			$link.attr( 'href', $link.attr( 'href' ).replace( '&action=' + action , '&action=' + otheraction ) );
should be

wgScript ?title= wgPageName (not wgTitle since that doens't include the namespace) & action= (un)watch
Comment 2 Brion Vibber 2011-02-13 21:51:19 UTC
Bump?
Comment 3 Krinkle 2011-02-20 00:12:36 UTC
Changing summary, it's not a regression since it was done the same way in the legacy script.

Fixed in r82498.
Comment 4 Brion Vibber 2011-12-20 18:40:01 UTC
That doesn't appear to fix the actual bug, which remains in 1.18.0 and trunk:

		var title = mw.util.getParamValue( 'title', link.href );
		$link.data( 'target', title.replace( /_/g, ' ' ) );
Comment 5 Brion Vibber 2011-12-20 18:54:11 UTC
This was seen to break the Map extension (depending on load order involving gadgets, extensions, and core) on occupywiki.org.uk, running 1.18.0.

Combination of:
* watch in wgActionPaths
* HotCat gadget
* Map extension

As far as I can tell, the ajax watch setup code's ready handler got called before the Map extension's ready handler when HotCat was present; when the watch code failed, the maps setup code didn't get run.
Comment 6 Brion Vibber 2011-12-20 22:25:41 UTC
The line above also tries to get an 'action' param from the same link; this one doesn't happen to crash but will fail to compare properly against 'unwatch'.
Comment 7 Brion Vibber 2011-12-20 22:27:39 UTC
Note that the error here is on setup.
Comment 8 Krinkle 2011-12-27 01:23:20 UTC
Re-fixed in r107354 (major rewrite).

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


Navigation
Links