r86464 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86463‎ | r86464 | r86465 >
Date:11:27, 20 April 2011
Author:catrope
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.17wmf1/RELEASE-NOTES (modified) (history)
  • /branches/wmf/1.17wmf1/includes/Article.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/AutoLoader.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/CategoryPage.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/DefaultSettings.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/DjVuImage.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/ImagePage.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/OutputPage.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/SpecialPage.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/normal/UtfNormal.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/specials/SpecialDisableAccount.php (deleted) (history)
  • /branches/wmf/1.17wmf1/languages/messages/MessagesEn.php (modified) (history)
  • /branches/wmf/1.17wmf1/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/maintenance/language/messages.inc
@@ -1094,7 +1094,6 @@
10951095 'right-reset-passwords',
10961096 'right-override-export-depth',
10971097 'right-sendemail',
1098 - 'right-disableaccount',
10991098 ),
11001099 'rightslog' => array(
11011100 'rightslog',
@@ -3212,17 +3211,6 @@
32133212 'sqlite-has-fts',
32143213 'sqlite-no-fts',
32153214 ),
3216 - 'disableaccount' => array(
3217 - 'disableaccount',
3218 - 'disableaccount-user',
3219 - 'disableaccount-reason',
3220 - 'disableaccount-confirm',
3221 - 'disableaccount-mustconfirm',
3222 - 'disableaccount-confirm',
3223 - 'disableaccount-nosuchuser',
3224 - 'disableaccount-success',
3225 - 'disableaccount-logentry',
3226 - ),
32273215 );
32283216
32293217 /** Comments for each block */
@@ -3436,5 +3424,4 @@
34373425 'db-error-messages' => 'Database error messages',
34383426 'html-forms' => 'HTML forms',
34393427 'sqlite' => 'SQLite database support',
3440 - 'disableaccount' => 'Special:DisableAccount',
34413428 );
Index: branches/wmf/1.17wmf1/includes/CategoryPage.php
@@ -197,6 +197,9 @@
198198 * entry in the categorylinks table is Category:A, not A, which it SHOULD be.
199199 * Workaround: If sortkey == "Category:".$title, than use $title for sorting,
200200 * else use sortkey...
 201+ *
 202+ * @param Title $title
 203+ * @param string $sortkey The human-readable sortkey (before transforming to icu or whatever).
201204 */
202205 function getSubcategorySortChar( $title, $sortkey ) {
203206 global $wgContLang;
@@ -299,7 +302,8 @@
300303 array( 'page', 'categorylinks', 'category' ),
301304 array( 'page_id', 'page_title', 'page_namespace', 'page_len',
302305 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
303 - 'cat_subcats', 'cat_pages', 'cat_files', 'cl_sortkey_prefix' ),
 306+ 'cat_subcats', 'cat_pages', 'cat_files',
 307+ 'cl_sortkey_prefix', 'cl_collation' ),
304308 array_merge( array( 'cl_to' => $this->title->getDBkey() ), $extraConds ),
305309 __METHOD__,
306310 array(
@@ -316,22 +320,29 @@
317321 $count = 0;
318322 foreach ( $res as $row ) {
319323 $title = Title::newFromRow( $row );
320 - $rawSortkey = $row->cl_sortkey;
 324+ if ( $row->cl_collation === '' ) {
 325+ // Hack to make sure that while updating from 1.16 schema
 326+ // and db is inconsistent, that the sky doesn't fall.
 327+ // See r83544. Could perhaps be removed in a couple decades...
 328+ $humanSortkey = $row->cl_sortkey;
 329+ } else {
 330+ $humanSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
 331+ }
321332
322333 if ( ++$count > $this->limit ) {
323334 # We've reached the one extra which shows that there
324335 # are additional pages to be had. Stop here...
325 - $this->nextPage[$type] = $rawSortkey;
 336+ $this->nextPage[$type] = $humanSortkey;
326337 break;
327338 }
328339
329340 if ( $title->getNamespace() == NS_CATEGORY ) {
330341 $cat = Category::newFromRow( $row, $title );
331 - $this->addSubcategoryObject( $cat, $rawSortkey, $row->page_len );
 342+ $this->addSubcategoryObject( $cat, $humanSortkey, $row->page_len );
332343 } elseif ( $title->getNamespace() == NS_FILE ) {
333 - $this->addImage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect );
 344+ $this->addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
334345 } else {
335 - $this->addPage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect );
 346+ $this->addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
336347 }
337348 }
338349 }
Property changes on: branches/wmf/1.17wmf1/includes/CategoryPage.php
___________________________________________________________________
Modified: svn:mergeinfo
339350 Merged /trunk/phase3/includes/CategoryPage.php:r85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
Index: branches/wmf/1.17wmf1/includes/Article.php
@@ -3250,6 +3250,7 @@
32513251 $dbw->delete( 'templatelinks', array( 'tl_from' => $id ) );
32523252 $dbw->delete( 'externallinks', array( 'el_from' => $id ) );
32533253 $dbw->delete( 'langlinks', array( 'll_from' => $id ) );
 3254+ $dbw->delete( 'iwlinks', array( 'iwl_from' => $id ) );
32543255 $dbw->delete( 'redirect', array( 'rd_from' => $id ) );
32553256 }
32563257
Property changes on: branches/wmf/1.17wmf1/includes/Article.php
___________________________________________________________________
Modified: svn:mergeinfo
32573258 Merged /trunk/phase3/includes/Article.php:r85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
Index: branches/wmf/1.17wmf1/includes/ImagePage.php
@@ -990,16 +990,16 @@
991991
992992 // Uploading user
993993 $row .= '<td>';
994 - if ( $local ) {
995 - // Hide deleted usernames
996 - if ( $file->isDeleted( File::DELETED_USER ) ) {
997 - $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
 994+ // Hide deleted usernames
 995+ if ( $file->isDeleted( File::DELETED_USER ) ) {
 996+ $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
 997+ } else {
 998+ if ( $local ) {
 999+ $row .= $this->skin->userLink( $user, $usertext ) . ' <span style="white-space: nowrap;">' .
 1000+ $this->skin->userToolLinks( $user, $usertext ) . '</span>';
9981001 } else {
999 - $row .= $this->skin->userLink( $user, $usertext ) . " <span style='white-space: nowrap;'>" .
1000 - $this->skin->userToolLinks( $user, $usertext ) . "</span>";
 1002+ $row .= htmlspecialchars( $usertext );
10011003 }
1002 - } else {
1003 - $row .= htmlspecialchars( $usertext );
10041004 }
10051005 $row .= '</td><td>';
10061006
Index: branches/wmf/1.17wmf1/includes/OutputPage.php
@@ -2280,7 +2280,9 @@
22812281 $wgUser->getOption( 'editondblclick' )
22822282 )
22832283 {
2284 - $bodyAttrs['ondblclick'] = "document.location = '" . Xml::escapeJsString( $this->getTitle()->getEditURL() ) . "'";
 2284+ $editUrl = $this->getTitle()->getLocalUrl( $sk->editUrlOptions() );
 2285+ $bodyAttrs['ondblclick'] = "document.location = '" .
 2286+ Xml::escapeJsString( $editUrl ) . "'";
22852287 }
22862288
22872289 # Class bloat
Property changes on: branches/wmf/1.17wmf1/includes/OutputPage.php
___________________________________________________________________
Modified: svn:mergeinfo
22882290 Merged /trunk/phase3/includes/OutputPage.php:r85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
Index: branches/wmf/1.17wmf1/includes/AutoLoader.php
@@ -633,7 +633,6 @@
634634 'SpecialBookSources' => 'includes/specials/SpecialBooksources.php',
635635 'SpecialCategories' => 'includes/specials/SpecialCategories.php',
636636 'SpecialComparePages' => 'includes/specials/SpecialComparePages.php',
637 - 'SpecialDisableAccount' => 'includes/specials/SpecialDisableAccount.php',
638637 'SpecialExport' => 'includes/specials/SpecialExport.php',
639638 'SpecialFilepath' => 'includes/specials/SpecialFilepath.php',
640639 'SpecialImport' => 'includes/specials/SpecialImport.php',
Property changes on: branches/wmf/1.17wmf1/includes/AutoLoader.php
___________________________________________________________________
Modified: svn:mergeinfo
641640 Merged /trunk/phase3/includes/AutoLoader.php:r85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
Index: branches/wmf/1.17wmf1/includes/DefaultSettings.php
@@ -3324,11 +3324,6 @@
33253325 // For private suppression log access
33263326 #$wgGroupPermissions['suppress']['suppressionlog'] = true;
33273327
3328 -// Permission to disable user accounts
3329 -// Note that disabling an account is not reversible without a system administrator
3330 -// who has direct access to the database
3331 -#$wgGroupPermissions['bureaucrat']['disableaccount'] = true;
3332 -
33333328 /**
33343329 * The developer group is deprecated, but can be activated if need be
33353330 * to use the 'lockdb' and 'unlockdb' special pages. Those require
Property changes on: branches/wmf/1.17wmf1/includes/DefaultSettings.php
___________________________________________________________________
Modified: svn:mergeinfo
33363331 Merged /trunk/phase3/includes/DefaultSettings.php:r85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
Index: branches/wmf/1.17wmf1/includes/specials/SpecialDisableAccount.php
@@ -1,73 +0,0 @@
2 -<?php
3 -
4 -class SpecialDisableAccount extends SpecialPage {
5 - function __construct() {
6 - parent::__construct( 'DisableAccount', 'disableaccount',
7 - true, array( $this, 'show' ) );
8 - }
9 -
10 - public function show( $par ) {
11 - $formFields = array(
12 - 'account' => array(
13 - 'type' => 'text',
14 - 'validation-callback' => array( __CLASS__, 'validateUser' ),
15 - 'label-message' => 'disableaccount-user',
16 - ),
17 - 'comment' => array(
18 - 'type' => 'text',
19 - 'label-message' => 'disableaccount-reason',
20 - ),
21 - 'confirm' => array(
22 - 'type' => 'toggle',
23 - 'validation-callback' => array( __CLASS__, 'checkConfirmation' ),
24 - 'label-message' => 'disableaccount-confirm',
25 - ),
26 - );
27 -
28 - $htmlForm = new HTMLForm( $formFields, 'disableaccount' );
29 -
30 - $htmlForm->setSubmitCallback( array( __CLASS__, 'submit' ) );
31 - $htmlForm->setTitle( $this->getTitle() );
32 -
33 - $htmlForm->show();
34 - }
35 -
36 - static function validateUser( $field, $allFields ) {
37 - $u = User::newFromName( $field );
38 -
39 - if ( $u && $u->getID() != 0 ) {
40 - return true;
41 - } else {
42 - return wfMsgExt( 'disableaccount-nosuchuser', 'parseinline', array( $field ) );
43 - }
44 - }
45 -
46 - static function checkConfirmation( $field, $allFields ) {
47 - if ( $field ) {
48 - return true;
49 - } else {
50 - return wfMsgExt( 'disableaccount-mustconfirm', 'parseinline' );
51 - }
52 - }
53 -
54 - static function submit( $fields ) {
55 - $user = User::newFromName( $fields['account'] );
56 -
57 - $user->setPassword( null );
58 - $user->setEmail( null );
59 - $user->setToken();
60 - $user->addGroup( 'inactive' );
61 -
62 - $user->saveSettings();
63 - $user->invalidateCache();
64 -
65 - $logPage = new LogPage( 'rights' );
66 -
67 - $logPage->addEntry( 'disable', $user->getUserPage(), $fields['comment'] );
68 -
69 - global $wgOut;
70 - $wgOut->addWikiMsg( 'disableaccount-success', $user->getName() );
71 -
72 - return true;
73 - }
74 -}
\ No newline at end of file
Index: branches/wmf/1.17wmf1/includes/SpecialPage.php
@@ -133,7 +133,6 @@
134134 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
135135 'Activeusers' => 'SpecialActiveUsers',
136136 'Userrights' => 'UserrightsPage',
137 - 'DisableAccount' => 'SpecialDisableAccount',
138137
139138 # Recent changes and logs
140139 'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ),
@@ -1063,4 +1062,4 @@
10641063 global $wgUser;
10651064 return SpecialPage::getTitleFor( 'Listfiles', $wgUser->getName() );
10661065 }
1067 -}
\ No newline at end of file
 1066+}
Property changes on: branches/wmf/1.17wmf1/includes/SpecialPage.php
___________________________________________________________________
Modified: svn:mergeinfo
10681067 Merged /trunk/phase3/includes/SpecialPage.php:r85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
Index: branches/wmf/1.17wmf1/includes/normal/UtfNormal.php
@@ -79,19 +79,30 @@
8080 * @return string a clean, shiny, normalized UTF-8 string
8181 */
8282 static function cleanUp( $string ) {
83 - if( NORMALIZE_ICU || NORMALIZE_INTL ) {
84 - # We exclude a few chars that ICU would not.
85 - $string = preg_replace(
86 - '/[\x00-\x08\x0b\x0c\x0e-\x1f]/',
87 - UTF8_REPLACEMENT,
88 - $string );
89 - $string = str_replace( UTF8_FFFE, UTF8_REPLACEMENT, $string );
90 - $string = str_replace( UTF8_FFFF, UTF8_REPLACEMENT, $string );
 83+ if( NORMALIZE_ICU ) {
 84+ $string = self::replaceForNativeNormalize( $string );
9185
9286 # UnicodeString constructor fails if the string ends with a
9387 # head byte. Add a junk char at the end, we'll strip it off.
94 - if ( NORMALIZE_ICU ) return rtrim( utf8_normalize( $string . "\x01", UNORM_NFC ), "\x01" );
95 - if ( NORMALIZE_INTL ) return normalizer_normalize( $string, Normalizer::FORM_C );
 88+ return rtrim( utf8_normalize( $string . "\x01", UNORM_NFC ), "\x01" );
 89+ } elseif( NORMALIZE_INTL ) {
 90+ $string = self::replaceForNativeNormalize( $string );
 91+ $norm = normalizer_normalize( $string, Normalizer::FORM_C );
 92+ if( $norm === null || $norm === false ) {
 93+ # normalizer_normalize will either return false or null
 94+ # (depending on which doc you read) if invalid utf8 string.
 95+ # quickIsNFCVerify cleans up invalid sequences.
 96+
 97+ if( UtfNormal::quickIsNFCVerify( $string ) ) {
 98+ # if that's true, the string is actually already normal.
 99+ return $string;
 100+ } else {
 101+ # Now we are valid but non-normal
 102+ return normalizer_normalize( $string, Normalizer::FORM_C );
 103+ }
 104+ } else {
 105+ return $norm;
 106+ }
96107 } elseif( UtfNormal::quickIsNFCVerify( $string ) ) {
97108 # Side effect -- $string has had UTF-8 errors cleaned up.
98109 return $string;
@@ -748,4 +759,20 @@
749760 }
750761 return $out;
751762 }
 763+ /**
 764+ * Function to replace some characters that we don't want
 765+ * but most of the native normalize functions keep.
 766+ *
 767+ * @param $string String The string
 768+ * @return String String with the character codes replaced.
 769+ */
 770+ private static function replaceForNativeNormalize( $string ) {
 771+ $string = preg_replace(
 772+ '/[\x00-\x08\x0b\x0c\x0e-\x1f]/',
 773+ UTF8_REPLACEMENT,
 774+ $string );
 775+ $string = str_replace( UTF8_FFFE, UTF8_REPLACEMENT, $string );
 776+ $string = str_replace( UTF8_FFFF, UTF8_REPLACEMENT, $string );
 777+ return $string;
 778+ }
752779 }
Index: branches/wmf/1.17wmf1/includes/DjVuImage.php
@@ -254,8 +254,7 @@
255255 $txt = wfShellExec( $cmd, $retval );
256256 wfProfileOut( 'djvutxt' );
257257 if( $retval == 0) {
258 - # Get rid of invalid UTF-8, strip control characters
259 - $txt = UtfNormal::cleanUp( $txt );
 258+ # Strip some control characters
260259 $txt = preg_replace( "/[\013\035\037]/", "", $txt );
261260 $reg = <<<EOR
262261 /\(page\s[\d-]*\s[\d-]*\s[\d-]*\s[\d-]*\s*"
@@ -279,7 +278,8 @@
280279 }
281280
282281 function pageTextCallback( $matches ) {
283 - return '<PAGE value="' . htmlspecialchars( $matches[1] ) . '" />';
 282+ # Get rid of invalid UTF-8, strip control characters
 283+ return '<PAGE value="' . htmlspecialchars( UtfNormal::cleanUp( $matches[1] ) ) . '" />';
284284 }
285285
286286 /**
Index: branches/wmf/1.17wmf1/languages/messages/MessagesEn.php
@@ -1931,7 +1931,6 @@
19321932 'right-reset-passwords' => "Reset other users' passwords",
19331933 'right-override-export-depth' => 'Export pages including linked pages up to a depth of 5',
19341934 'right-sendemail' => 'Send e-mail to other users',
1935 -'right-disableaccount' => 'Disable accounts',
19361935
19371936 # User rights log
19381937 'rightslog' => 'User rights log',
@@ -4366,18 +4365,4 @@
43674366 # SQLite database support
43684367 'sqlite-has-fts' => '$1 with full-text search support',
43694368 'sqlite-no-fts' => '$1 without full-text search support',
4370 -
4371 -# Special:DisableAccount
4372 -'disableaccount' => 'Disable a user account',
4373 -'disableaccount-user' => 'Username:',
4374 -'disableaccount-reason' => 'Reason:',
4375 -'disableaccount-confirm' => "Disable this user account.
4376 -The user will not be able to log in, reset their password, or receive e-mail notifications.
4377 -If the user is currently logged in anywhere, they will be immediately logged out.
4378 -''Note that disabling an account is not reversible without system administrator intervention.''",
4379 -'disableaccount-mustconfirm' => 'You must confirm that you wish to disable this account.',
4380 -'disableaccount-nosuchuser' => 'The user account "$1" does not exist.',
4381 -'disableaccount-success' => 'The user account "$1" has been permanently disabled.',
4382 -'disableaccount-logentry' => 'permanently disabled the user account [[$1]]',
4383 -
43844369 );
Property changes on: branches/wmf/1.17wmf1/languages/messages/MessagesEn.php
___________________________________________________________________
Modified: svn:mergeinfo
43854370 Merged /trunk/phase3/languages/messages/MessagesEn.php:r85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
Index: branches/wmf/1.17wmf1/RELEASE-NOTES
@@ -505,6 +505,9 @@
506506 since length can vary by localization.
507507 * (bug 28242) Make redirects generated by urls containing a local interwiki
508508 prefix be a 301 instead of a 302.
 509+* (bug 28306) Fix exposure of suppressed usernames in ForeignDBRepo
 510+* (bug 28444) Fix regression: edit-on-doubleclick retains revision id again
 511+* UtfNormal::cleanUp on an invalid utf-8 sequence no longer returns false if intl installed.
509512
510513 === API changes in 1.18 ===
511514 * (bug 26339) Throw warning when truncating an overlarge API result
Property changes on: branches/wmf/1.17wmf1/RELEASE-NOTES
___________________________________________________________________
Modified: svn:mergeinfo
512515 Merged /trunk/phase3/RELEASE-NOTES:r85377,85555,85583,86100,86121,86130,86142,86146,86183,86210

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85377Workaround for bug 28146: running out of memory during Unicode validation/nor...brion20:59, 4 April 2011
r85555* (bug 28306) Fix exposure of suppressed usernames in ForeignDBRepo...brion18:23, 6 April 2011
r85583* (bug 28444) Fix regression: edit-on-doubleclick retains revision id again...brion21:58, 6 April 2011
r86100(bug 28540) revert r83544 - It really breaks things when using uca-default co...bawolff23:28, 14 April 2011
r86121(follow-up r86100) Make categorypage not die as much while transitioning betw...bawolff17:23, 15 April 2011
r86130(follow-up r69626) Make it so the intl normalizer_normalize function is not...bawolff18:39, 15 April 2011
r86142(follow-up r86121) Use strict comparision....bawolff21:53, 15 April 2011
r86146Revert r77555 and followups r77563, r77572, r78116 (merge DisableAccount to c...demon22:49, 15 April 2011
r86183* (bug 28568) Entries in the iwlinks table are now removed on page deletionialex07:46, 16 April 2011
r86210(follow-up r86130) the normalizer_normalize function doesn't replace things l...bawolff15:32, 16 April 2011

Status & tagging log