r62827 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62826‎ | r62827 | r62828 >
Date:13:06, 22 February 2010
Author:vasilievvv
Status:ok (Comments)
Tags:
Comment:
Fix r61737 (mostly per Tim Starling's comments):
* Cleanup messages output in Special:CentralAuth
* Throw exception if unable to determine home wiki
* Fix ucfirst spelling
* Use array_chunk() instead of DIY code
* Reword $wgCentralAuthUDPAddress description
* Rename cursor variable to wgCursorPosition so it does not pollute global JS namespace
* Fix SQL: update main schema file and change gu_locked/gu_hidden indices
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuthUser.php (modified) (history)
  • /trunk/extensions/CentralAuth/SpecialCentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/central-auth.sql (modified) (history)
  • /trunk/extensions/CentralAuth/centralauth.js (modified) (history)
  • /trunk/extensions/CentralAuth/db_patches/patch-gu_hidden.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/centralauth.js
@@ -1,8 +1,10 @@
2 -cursor = { x : 0, y : 0 };
3 -function updateCursorPosition(e) {
 2+wgCursorPosition = { x : 0, y : 0 };
 3+function updateCursorPosition( e ) {
44 e = e || window.event;
5 - cursor.x = e.clientX + ( document.documentElement.scrollLeft || document.body.scrollLeft ) - document.documentElement.clientLeft;
6 - cursor.y = e.clientY + ( document.documentElement.scrollTop || document.body.scrollTop ) - document.documentElement.clientTop;
 5+ wgCursorPosition.x = e.clientX + ( document.documentElement.scrollLeft || document.body.scrollLeft )
 6+ - document.documentElement.clientLeft;
 7+ wgCursorPosition.y = e.clientY + ( document.documentElement.scrollTop || document.body.scrollTop )
 8+ - document.documentElement.clientTop;
79 }
810 document.onmousemove = updateCursorPosition;
911
@@ -16,11 +18,12 @@
1719 methodHint = document.createElement( 'div' );
1820 methodHint.innerHTML = helpHtml;
1921 methodHint.setAttribute( 'class', 'merge-method-help-div' );
20 - methodHint.style.left = cursor.x + 'px';
21 - methodHint.style.top = cursor.y + 'px';
 22+ methodHint.style.left = wgCursorPosition.x + 'px';
 23+ methodHint.style.top = wgCursorPosition.y + 'px';
2224 methodHint.setAttribute( 'onclick', 'hideMethodHint()' );
2325 document.getElementById( 'globalWrapper' ).appendChild( methodHint );
2426 }
 27+
2528 function hideMethodHint() {
2629 if( methodHint ) {
2730 methodHint.parentNode.removeChild( methodHint );
Index: trunk/extensions/CentralAuth/central-auth.sql
@@ -72,7 +72,7 @@
7373
7474 -- If true, this account should be hidden from most public user lists.
7575 -- Used for "deleting" accounts without breaking referential integrity.
76 - gu_hidden bool not null default 0,
 76+ gu_hidden varbinary(255) not null default '',
7777
7878 -- Registration time
7979 gu_registration varchar(14) binary,
@@ -86,7 +86,10 @@
8787
8888 primary key (gu_id),
8989 unique key (gu_name),
90 - key (gu_email)
 90+ key (gu_email),
 91+
 92+ key gu_locked( gu_name(255), gu_locked ),
 93+ key gu_hidden( gu_name(255), gu_hidden(255) )
9194 ) /*$wgDBTableOptions*/;
9295
9396 --
Index: trunk/extensions/CentralAuth/db_patches/patch-gu_hidden.sql
@@ -13,5 +13,5 @@
1414 -- There's also "suppressed" level, which wasn't used before this schema change
1515
1616 ALTER TABLE globaluser
17 - ADD INDEX gu_locked( gu_locked ),
18 - ADD INDEX gu_hidden( gu_hidden(255) );
 17+ ADD INDEX gu_locked( gu_name(255), gu_locked ),
 18+ ADD INDEX gu_hidden( gu_name(255), gu_hidden(255) );
Index: trunk/extensions/CentralAuth/CentralAuthUser.php
@@ -1057,11 +1057,9 @@
10581058 'reason' => $reason,
10591059 );
10601060 $jobs = array();
1061 - $step = $wgCentralAuthWikisPerSuppressJob;
1062 - for( $jobCount = 0; $jobCount < count( $this->mAttachedArray ); $jobCount += $step ) {
1063 - $length = $jobCount + $step > count( $this->mAttachedArray ) ?
1064 - $jobCount - $step : $step;
1065 - $jobParams['wikis'] = array_slice( $this->mAttachedArray, $jobCount, $length );
 1061+ $chunks = array_chunk( $this->mAttachedArray, $wgCentralAuthWikisPerSuppressJob );
 1062+ foreach( $chunks as $wikis ) {
 1063+ $jobParams['wikis'] = $wikis;
10661064 $jobs[] = Job::factory(
10671065 'crosswikiSuppressUser',
10681066 Title::makeTitleSafe( NS_USER, $this->getName() ),
Index: trunk/extensions/CentralAuth/CentralAuth.php
@@ -123,7 +123,7 @@
124124 $wgCentralAuthCreateOnView = false;
125125
126126 /**
127 - * UPD-transmissed RC settings
 127+ * Settings for sending the CentralAuth events to the RC-to-UDP system
128128 */
129129 $wgCentralAuthUDPAddress = false;
130130 $wgCentralAuthNew2UDPPrefix = '';
Index: trunk/extensions/CentralAuth/SpecialCentralAuth.php
@@ -204,7 +204,7 @@
205205
206206 function showStatusError( $wikitext ) {
207207 global $wgOut;
208 - $wrap = Xml::tags( 'div', array( 'class' => 'error' ), $s );
 208+ $wrap = Xml::tags( 'div', array( 'class' => 'error' ), $wikitext );
209209 $wgOut->addHTML( $wgOut->parse( $wrap, /*linestart*/true, /*uilang*/true ) );
210210 }
211211
@@ -278,7 +278,8 @@
279279 $out = '<fieldset id="mw-centralauth-info">';
280280 $out .= '<legend>' . wfMsgHtml( 'centralauth-admin-info-header' ) . '</legend>';
281281 foreach( $attribs as $tag => $data ) {
282 - $out .= '<p><strong>' . wfMsg( "centralauth-admin-info-$tag" ) . '</strong> ' . $data . '</p>';
 282+ $out .= '<p><strong>' . wfMsgHtml( "centralauth-admin-info-$tag" ) . '</strong> ' .
 283+ htmlspecialchars( $data ) . '</p>';
283284 }
284285 $out .= '</fieldset>';
285286 $wgOut->addHTML( $out );
@@ -290,8 +291,8 @@
291292 $remainder = $this->mUnattachedLocalAccounts;
292293
293294 $legend = $this->mCanUnmerge ?
294 - wfMsg( 'centralauth-admin-list-legend-rw' ) :
295 - wfMsg( 'centralauth-admin-list-legend-ro' );
 295+ wfMsgHtml( 'centralauth-admin-list-legend-rw' ) :
 296+ wfMsgHtml( 'centralauth-admin-list-legend-ro' );
296297
297298 $wgOut->addHTML( "<fieldset><legend>{$legend}</legend>" );
298299 $wgOut->addHTML( $this->listHeader() );
@@ -346,7 +347,7 @@
347348
348349 function listRemainder( $list ) {
349350 ksort( $list );
350 - $notMerged = wfMsg( 'centralauth-admin-unattached' );
 351+ $notMerged = wfMsgExt( 'centralauth-admin-unattached', array( 'parseinline' ) );
351352 $rows = array();
352353 foreach ( $list as $row ) {
353354 $rows[] = '<tr class="unattached-row"><td>' .
@@ -372,9 +373,9 @@
373374 function formatMergeMethod( $method ) {
374375 global $wgExtensionAssetsPath;
375376
376 - $img = "{$wgExtensionAssetsPath}/CentralAuth/icons/merged-{$method}.png";
 377+ $img = htmlspecialchars( "{$wgExtensionAssetsPath}/CentralAuth/icons/merged-{$method}.png" );
377378 $brief = wfMsgHtml( "centralauth-merge-method-{$method}" );
378 - return "<img src=\"{$img}\" alt=\"{$brief}\" />" .
 379+ return "<img src=\"{$img}\" alt=\"{$brief}\" title=\"{$brief}\"/>" .
379380 "<span class=\"merge-method-help\" title=\"{$brief}\" onclick=\"showMethodHint('{$method}')\">(?)</span>";
380381 }
381382
@@ -586,7 +587,7 @@
587588 }
588589
589590 // Should not happen.
590 - return '';
 591+ throw new MWException( 'Failed to determine home wiki' );
591592 }
592593
593594 function evaluateTotalEditcount() {
@@ -601,7 +602,7 @@
602603 global $wgOut, $wgLang;
603604 $js = "wgMergeMethodDescriptions = {\n";
604605 foreach( array( 'primary', 'new', 'empty', 'password', 'mail', 'admin', 'login' ) as $method ) {
605 - $short = Xml::encodeJsVar( $wgLang->ucFirst( wfMsgHtml( "centralauth-merge-method-{$method}" ) ) );
 606+ $short = Xml::encodeJsVar( $wgLang->ucfirst( wfMsgHtml( "centralauth-merge-method-{$method}" ) ) );
606607 $desc = Xml::encodeJsVar( wfMsgWikiHtml( "centralauth-merge-method-{$method}-desc" ) );
607608 $js .= "\t'{$method}' : { 'short' : {$short}, 'desc' : {$desc} },\n";
608609 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r63568MFT r62827: various Special:CentralAuth fixes per CRtstarling19:41, 10 March 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61737Rewrite CentralAuth admin form and lock/hide mechanism. Changes:...vasilievvv02:41, 31 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   19:37, 10 March 2010

Looks good, thanks. I'll backport it.

Status & tagging log