r90133 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90132‎ | r90133 | r90134 >
Date:18:32, 15 June 2011
Author:janpaul123
Status:resolved (Comments)
Tags:
Comment:
Reverted r88565 for now for 1.17wmf1 compatibility
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.hooks.php (modified) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/WikiLove.hooks.php
@@ -43,22 +43,25 @@
4444 }
4545
4646 /**
47 - * Adds the required module if we are on a user (talk) page.
 47+ * Adds the required module and edit token JS if we are on a user (talk) page.
4848 *
4949 * @param $output
5050 * @param $skin Skin
5151 */
5252 public static function beforePageDisplay( $out, $skin ) {
5353 global $wgWikiLoveGlobal, $wgUser;
54 - if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) {
55 - return true;
56 - }
 54+ if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) return true;
5755
5856 $title = self::getUserTalkPage( $skin->getTitle() );
5957 if ( !is_null( $title ) ) {
6058 $out->addModules( 'ext.wikiLove.icon' );
6159 $out->addModules( 'ext.wikiLove.init' );
6260 self::$recipient = $title->getText();
 61+ $out->addInlineScript(
 62+ 'jQuery( document ).ready( function() {
 63+ jQuery.wikiLove.editToken = ' . FormatJson::encode( $wgUser->edittoken() ) . ';
 64+ } );'
 65+ );
6366 }
6467 return true;
6568 }
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
@@ -7,6 +7,7 @@
88 currentSubtypeId = null, // id of the currently selected subtype (e.g. 'original' or 'special')
99 currentTypeOrSubtype = null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.)
1010 previewData = null, // data of the currently previewed thing is set here
 11+ editToken = '', // edit token used for the final AJAX call (deprecated after 1.17)
1112 emailable = false,
1213 gallery = {};
1314
@@ -384,7 +385,7 @@
385386 'text': wikitext,
386387 'message': message,
387388 'subject': subject,
388 - 'token': mw.user.tokens.get( 'editToken' )
 389+ 'token': $.wikiLove.editToken // after 1.17 this can become mw.user.tokens.get( 'editToken' )
389390 };
390391
391392 if ( email ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r90134Followup to r90133 as this was still incorrect.janpaul12318:39, 15 June 2011
r901351.17wmf1: MFT r90133, r90134catrope18:44, 15 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88565Using the new mw.user.tokens (Introduced in r88553).krinkle08:47, 22 May 2011

Comments

#Comment by Catrope (talk | contribs)   18:35, 15 June 2011

Still not 1.17wmf1-compatible: jQuery is not in the head in 1.17, so you can't use addInlineScript that way. You shouldn't be using an inline script anyway; instead export the variable properly using the MakeGlobalVariablesScript hook.

Status & tagging log