r101622 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101621‎ | r101622 | r101623 >
Date:13:15, 2 November 2011
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
Fix fatal errors in r101612 and r101613
Modified paths:
  • /trunk/extensions/Translate/api/ApiGroupReview.php (modified) (history)
  • /trunk/extensions/Translate/api/ApiTranslationReview.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/api/ApiTranslationReview.php
@@ -14,6 +14,7 @@
1515 */
1616 class ApiTranslationReview extends ApiBase {
1717 protected static $right = 'translate-messagereview';
 18+ protected static $salt = 'translate-messagereview';
1819
1920 public function execute() {
2021 global $wgUser;
@@ -77,7 +78,7 @@
7879 }
7980
8081 public function getTokenSalt() {
81 - return 'translate-messagereview';
 82+ return self::$salt;
8283 }
8384
8485 public function getAllowedParams() {
@@ -136,7 +137,7 @@
137138 return $cachedToken;
138139 }
139140
140 - $cachedToken = $wgUser->editToken( $this->getTokenSalt() );
 141+ $cachedToken = $wgUser->editToken( self::$salt );
141142 return $cachedToken;
142143 }
143144
Index: trunk/extensions/Translate/api/ApiGroupReview.php
@@ -14,6 +14,7 @@
1515 */
1616 class ApiGroupReview extends ApiBase {
1717 protected static $right = 'translate-groupreview';
 18+ protected static $salt = 'translate-groupreview';
1819
1920 public function execute() {
2021 global $wgUser, $wgTranslateWorkflowStates;
@@ -71,7 +72,7 @@
7273 }
7374
7475 public function getTokenSalt() {
75 - return 'translate-groupreview';
 76+ return self::$salt;
7677 }
7778
7879 public function getAllowedParams() {
@@ -142,7 +143,7 @@
143144 return $cachedToken;
144145 }
145146
146 - $cachedToken = $wgUser->editToken( $this->getTokenSalt() );
 147+ $cachedToken = $wgUser->editToken( self::$salt );
147148 return $cachedToken;
148149 }
149150

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101612Code cleanupnikerabbit10:57, 2 November 2011
r101613Api module for group review...nikerabbit10:59, 2 November 2011

Comments

#Comment by Amire80 (talk | contribs)   12:00, 4 November 2011

Why replace $this->getTokenSalt() with self::$salt? Just a shortcut or is there a functional meaning?

#Comment by Nikerabbit (talk | contribs)   12:27, 4 November 2011

The hook function is static, it can't call $this->anything. The motivation for the original change was that I was developing groupreview API module, I had changed token name in one place but forgot the another and wondered why it doesn't work.

Status & tagging log