Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/111796
Change subject: Avoid failing if calling the exposed function but no watch/unwatch link was found for whatever reason. ...................................................................... Avoid failing if calling the exposed function but no watch/unwatch link was found for whatever reason. Change-Id: I6ee9a7ee6b7c0fc7a5444674afd1ed6f8cacc858 --- M resources/mediawiki.page/mediawiki.page.watch.ajax.js 1 file changed, 7 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/96/111796/1 diff --git a/resources/mediawiki.page/mediawiki.page.watch.ajax.js b/resources/mediawiki.page/mediawiki.page.watch.ajax.js index ef287c4..c6a9834 100644 --- a/resources/mediawiki.page/mediawiki.page.watch.ajax.js +++ b/resources/mediawiki.page/mediawiki.page.watch.ajax.js @@ -19,6 +19,12 @@ function updateWatchLink( $link, action, state ) { var accesskeyTip, msgKey, $li, otherAction; + // Don't fail if no link was found or no action was given, + // this can happen when calling the exposed function and the link was changed by a user script + if ( !$link || !$link.length || !action ) { + return; + } + // message keys 'watch', 'watching', 'unwatch' or 'unwatching'. msgKey = state === 'loading' ? action + 'ing' : action; otherAction = action === 'watch' ? 'unwatch' : 'watch'; @@ -69,8 +75,6 @@ function mwUriGetAction( url ) { var action, actionPaths, key, i, m, parts; - actionPaths = mw.config.get( 'wgActionPaths' ); - // @todo Does MediaWiki give action path or query param // precedence ? If the former, move this to the bottom action = mw.util.getParamValue( 'action', url ); @@ -78,6 +82,7 @@ return action; } + actionPaths = mw.config.get( 'wgActionPaths' ); for ( key in actionPaths ) { if ( actionPaths.hasOwnProperty( key ) ) { parts = actionPaths[key].split( '$1' ); -- To view, visit https://gerrit.wikimedia.org/r/111796 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6ee9a7ee6b7c0fc7a5444674afd1ed6f8cacc858 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits