r77536 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77535‎ | r77536 | r77537 >
Date:20:22, 1 December 2010
Author:mah
Status:ok
Tags:
Comment:
random w/s cleanup
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/IP.php (modified) (history)
  • /trunk/phase3/includes/Licenses.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/includes/installer/CoreInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/Vector.php
@@ -373,26 +373,26 @@
374374 }
375375 $nav[$section][$key]['attributes'] =
376376 ' id="' . Sanitizer::escapeId( $xmlID ) . '"';
377 - if ( $nav[$section][$key]['class'] ) {
 377+ if ( $nav[$section][$key]['class'] ) {
378378 $nav[$section][$key]['attributes'] .=
379379 ' class="' . htmlspecialchars( $link['class'] ) . '"';
380380 unset( $nav[$section][$key]['class'] );
381 - }
 381+ }
382382 // We don't want to give the watch tab an accesskey if the page
383383 // is being edited, because that conflicts with the accesskey on
384384 // the watch checkbox. We also don't want to give the edit tab
385385 // an accesskey, because that's fairly superfluous and conflicts
386386 // with an accesskey (Ctrl-E) often used for editing in Safari.
387 - if (
 387+ if (
388388 in_array( $action, array( 'edit', 'submit' ) ) &&
389389 in_array( $key, array( 'edit', 'watch', 'unwatch' ) )
390390 ) {
391 - $nav[$section][$key]['key'] =
 391+ $nav[$section][$key]['key'] =
392392 $this->skin->tooltip( $xmlID );
393 - } else {
394 - $nav[$section][$key]['key'] =
 393+ } else {
 394+ $nav[$section][$key]['key'] =
395395 $this->skin->tooltipAndAccesskey( $xmlID );
396 - }
 396+ }
397397 }
398398 }
399399 $this->data['namespace_urls'] = $nav['namespaces'];
@@ -434,7 +434,7 @@
435435 $footerlinksClasses = array(
436436 'icons' => array( 'noprint' )
437437 );
438 -
 438+
439439 // Reduce footer links down to only those which are being used
440440 $validFooterLinks = array();
441441 foreach( $footerlinks as $category => $links ) {
Index: trunk/phase3/includes/User.php
@@ -556,7 +556,7 @@
557557 * either by batch processes or by user accounts which have
558558 * already been created.
559559 *
560 - * Additional blacklisting may be added here rather than in
 560+ * Additional blacklisting may be added here rather than in
561561 * isValidUserName() to avoid disrupting existing accounts.
562562 *
563563 * @param $name \string String to match
@@ -615,7 +615,7 @@
616616 return 'passwordtooshort';
617617 } elseif ( $lcPassword == $wgContLang->lc( $this->mName ) ) {
618618 return 'password-name-match';
619 - } elseif ( in_array( $lcPassword, $wgWeakPasswords ) ) {
 619+ } elseif ( in_array( $lcPassword, $wgWeakPasswords ) ) {
620620 return 'password-too-weak';
621621 } else {
622622 //it seems weird returning true here, but this is because of the
@@ -658,7 +658,7 @@
659659 [$rfc1034_ldh_str]+ # First domain part
660660 (\\.[$rfc1034_ldh_str]+)+ # Following part prefixed with a dot
661661 $ # End of string
662 - /ix" ; // case Insensitive, eXtended
 662+ /ix" ; // case Insensitive, eXtended
663663
664664 return (bool) preg_match( $HTML5_email_regexp, $addr );
665665 }
@@ -1762,11 +1762,11 @@
17631763 }
17641764
17651765 if( !$this->isValidPassword( $str ) ) {
1766 - global $wgMinimalPasswordLength;
 1766+ global $wgMinimalPasswordLength;
17671767 $valid = $this->getPasswordValidity( $str );
17681768 throw new PasswordError( wfMsgExt( $valid, array( 'parsemag' ),
17691769 $wgMinimalPasswordLength ) );
1770 - }
 1770+ }
17711771 }
17721772
17731773 if( !$wgAuth->setPassword( $this, $str ) ) {
@@ -2038,7 +2038,7 @@
20392039 global $wgMaxArticleSize; # Maximum article size, in Kb
20402040 $threshold = intval( $this->getOption( 'stubthreshold' ) );
20412041 if ( $threshold > $wgMaxArticleSize * 1024 ) {
2042 - # If they have set an impossible value, disable the preference
 2042+ # If they have set an impossible value, disable the preference
20432043 # so we can use the parser cache again.
20442044 $threshold = 0;
20452045 }
@@ -2248,7 +2248,7 @@
22492249 return $this->mSkin;
22502250 }
22512251 }
2252 -
 2252+
22532253 // Creates a Skin object, for getSkin()
22542254 private function createSkinObject() {
22552255 wfProfileIn( __METHOD__ );
@@ -2267,7 +2267,7 @@
22682268
22692269 $skin = Skin::newFromKey( $userSkin );
22702270 wfProfileOut( __METHOD__ );
2271 -
 2271+
22722272 return $skin;
22732273 }
22742274
@@ -2402,7 +2402,7 @@
24032403
24042404 // If an option is not set in $str, use the default value
24052405 $this->mOptions = self::getDefaultOptions();
2406 -
 2406+
24072407 $a = explode( "\n", $str );
24082408 foreach ( $a as $s ) {
24092409 $m = array();
@@ -2514,8 +2514,8 @@
25152515 'user_newpassword' => $this->mNewpassword,
25162516 'user_newpass_time' => $dbw->timestampOrNull( $this->mNewpassTime ),
25172517 'user_real_name' => $this->mRealName,
2518 - 'user_email' => $this->mEmail,
2519 - 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
 2518+ 'user_email' => $this->mEmail,
 2519+ 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
25202520 'user_options' => '',
25212521 'user_touched' => $dbw->timestamp( $this->mTouched ),
25222522 'user_token' => $this->mToken,
@@ -2672,7 +2672,7 @@
26732673 wfDeprecated( __METHOD__ );
26742674
26752675 // stubthreshold is only included below for completeness,
2676 - // since it disables the parser cache, its value will always
 2676+ // since it disables the parser cache, its value will always
26772677 // be 0 when this function is called by parsercache.
26782678
26792679 $confstr = $this->getOption( 'math' );
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1287,9 +1287,9 @@
12881288 */
12891289 function wfEscapeWikiText( $text ) {
12901290 $text = str_replace(
1291 - array( '[', '|', ']', '\'', 'ISBN ',
 1291+ array( '[', '|', ']', '\'', 'ISBN ',
12921292 'RFC ', '://', "\n=", '{{', '}}' ),
1293 - array( '[', '|', ']', ''', 'ISBN ',
 1293+ array( '[', '|', ']', ''', 'ISBN ',
12941294 'RFC ', '://', "\n=", '{{', '}}' ),
12951295 htmlspecialchars( $text )
12961296 );
@@ -1987,7 +1987,7 @@
19881988 $uts = 0;
19891989 $da = array();
19901990 $strtime = '';
1991 -
 1991+
19921992 if ( $ts === 0 ) {
19931993 $uts = time();
19941994 $strtime = "@$uts";
@@ -2034,8 +2034,8 @@
20352035 return false;
20362036 }
20372037
2038 -
20392038
 2039+
20402040 static $formats = array(
20412041 TS_UNIX => 'U',
20422042 TS_MW => 'YmdHis',
@@ -2058,7 +2058,7 @@
20592059 $ds = sprintf("%04d-%02d-%02dT%02d:%02d:%02d.00+00:00",
20602060 (int)$da[1], (int)$da[2], (int)$da[3],
20612061 (int)$da[4], (int)$da[5], (int)$da[6]);
2062 -
 2062+
20632063 $d = date_create( $ds, new DateTimeZone( 'GMT' ) );
20642064 } elseif ( $strtime ) {
20652065 $d = date_create( $strtime, new DateTimeZone( 'GMT' ) );
@@ -2081,12 +2081,12 @@
20822082 } elseif ( $strtime ) {
20832083 $uts = strtotime( $strtime );
20842084 }
2085 -
 2085+
20862086 if ( $uts === false ) {
20872087 wfDebug("wfTimestamp() can't parse the timestamp (non 32-bit time? Update php): $outputtype; $ts\n");
20882088 return false;
20892089 }
2090 -
 2090+
20912091 if ( TS_UNIX == $outputtype ) {
20922092 return $uts;
20932093 }
@@ -2510,7 +2510,7 @@
25112511 * @param $cmd String Command line, properly escaped for shell.
25122512 * @param &$retval optional, will receive the program's exit code.
25132513 * (non-zero is usually failure)
2514 - * @param $environ Array optional environment variables which should be
 2514+ * @param $environ Array optional environment variables which should be
25152515 * added to the executed command environment.
25162516 * @return collected stdout as a string (trailing newlines stripped)
25172517 */
@@ -2545,22 +2545,22 @@
25462546 $envcmd = '';
25472547 foreach( $environ as $k => $v ) {
25482548 if ( wfIsWindows() ) {
2549 - /* Surrounding a set in quotes (method used by wfEscapeShellArg) makes the quotes themselves
2550 - * appear in the environment variable, so we must use carat escaping as documented in
2551 - * http://technet.microsoft.com/en-us/library/cc723564.aspx
2552 - * Note however that the quote isn't listed there, but is needed, and the parentheses
 2549+ /* Surrounding a set in quotes (method used by wfEscapeShellArg) makes the quotes themselves
 2550+ * appear in the environment variable, so we must use carat escaping as documented in
 2551+ * http://technet.microsoft.com/en-us/library/cc723564.aspx
 2552+ * Note however that the quote isn't listed there, but is needed, and the parentheses
25532553 * are listed there but doesn't appear to need it.
25542554 */
25552555 $envcmd .= "set $k=" . preg_replace( '/([&|()<>^"])/', '^\\1', $v ) . ' && ';
25562556 } else {
2557 - /* Assume this is a POSIX shell, thus required to accept variable assignments before the command
 2557+ /* Assume this is a POSIX shell, thus required to accept variable assignments before the command
25582558 * http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01
25592559 */
25602560 $envcmd .= "$k=" . escapeshellarg( $v ) . ' ';
25612561 }
25622562 }
25632563 $cmd = $envcmd . $cmd;
2564 -
 2564+
25652565 if ( wfIsWindows() ) {
25662566 if ( version_compare( PHP_VERSION, '5.3.0', '<' ) && /* Fixed in 5.3.0 :) */
25672567 ( version_compare( PHP_VERSION, '5.2.1', '>=' ) || php_uname( 's' ) == 'Windows NT' ) )
@@ -3585,20 +3585,20 @@
35863586
35873587 /**
35883588 * Returns the PackageRepository object for interaction with the package repository.
3589 - *
3590 - * TODO: Make the repository type also configurable.
3591 - *
 3589+ *
 3590+ * TODO: Make the repository type also configurable.
 3591+ *
35923592 * @since 1.17
3593 - *
 3593+ *
35943594 * @return PackageRepository
35953595 */
35963596 function wfGetRepository() {
35973597 global $wgRepositoryApiLocation;
35983598 static $repository = false;
3599 -
 3599+
36003600 if ( $repository === false ) {
36013601 $repository = new DistributionRepository( $wgRepositoryApiLocation );
36023602 }
3603 -
 3603+
36043604 return $repository;
36053605 }
Index: trunk/phase3/includes/Licenses.php
@@ -31,7 +31,7 @@
3232 */
3333 public function __construct( $params ) {
3434 parent::__construct( $params );
35 -
 35+
3636 $this->msg = empty( $params['licenses'] ) ? wfMsgForContent( 'licenses' ) : $params['licenses'];
3737 $this->selected = null;
3838
@@ -105,7 +105,7 @@
106106 protected function outputOption( $text, $value, $attribs = null, $depth = 0 ) {
107107 $attribs['value'] = $value;
108108 if ( $value === $this->selected )
109 - $attribs['selected'] = 'selected';
 109+ $attribs['selected'] = 'selected';
110110 $val = str_repeat( /* &nbsp */ "\xc2\xa0", $depth * 2 ) . $text;
111111 return str_repeat( "\t", $depth ) . Xml::element( 'option', $attribs, $val ) . "\n";
112112 }
@@ -131,18 +131,18 @@
132132 */
133133 public function getInputHTML( $value ) {
134134 $this->selected = $value;
135 -
 135+
136136 $this->html = $this->outputOption( wfMsg( 'nolicense' ), '',
137137 (bool)$this->selected ? null : array( 'selected' => 'selected' ) );
138138 $this->makeHtml( $this->getLicenses() );
139 -
 139+
140140 $attribs = array(
141141 'name' => $this->mName,
142142 'id' => $this->mID
143143 );
144144 if ( !empty( $this->mParams['disabled'] ) )
145145 $attibs['disabled'] = 'disabled';
146 -
 146+
147147 return Html::rawElement( 'select', $attribs, $this->html );
148148 }
149149 }
Index: trunk/phase3/includes/installer/CoreInstaller.php
@@ -298,7 +298,7 @@
299299 /**
300300 * Get an array of install steps. These could be a plain key like the defaults
301301 * in $installSteps, or could be an array with a name and a specific callback
302 - * There must be a config-install-$step message defined per step, which will
 302+ * There must be a config-install-$step message defined per step, which will
303303 * be shown on install.
304304 *
305305 * @param $installer DatabaseInstaller so we can make callbacks
@@ -315,7 +315,7 @@
316316 array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
317317 );
318318 if( count( $this->getVar( '_Extensions' ) ) ) {
319 - array_unshift( $installSteps,
 319+ array_unshift( $installSteps,
320320 array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
321321 );
322322 }
@@ -374,9 +374,9 @@
375375 protected function generateSecretKey() {
376376 return $this->generateSecret( 'wgSecretKey' );
377377 }
378 -
 378+
379379 /**
380 - * Generate a secret value for a variable using either
 380+ * Generate a secret value for a variable using either
381381 * /dev/urandom or mt_rand() Produce a warning in the later case.
382382 *
383383 * @return Status
@@ -411,7 +411,7 @@
412412 }
413413
414414 /**
415 - * Generate a default $wgUpradeKey, Will warn if we had to use
 415+ * Generate a default $wgUpradeKey, Will warn if we had to use
416416 * mt_rand() instead of /dev/urandom
417417 *
418418 * @return Status
@@ -453,7 +453,7 @@
454454
455455 /**
456456 * Insert Main Page with default content.
457 - *
 457+ *
458458 * @return Status
459459 */
460460 protected function createMainpage( DatabaseInstaller &$installer ) {
@@ -468,9 +468,9 @@
469469 User::newFromName( 'MediaWiki Default' ) );
470470 } catch (MWException $e) {
471471 //using raw, because $wgShowExceptionDetails can not be set yet
472 - $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
 472+ $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
473473 }
474 -
 474+
475475 return $status;
476476 }
477477
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -5,7 +5,7 @@
66 * @file
77 * @ingroup Deployment
88 */
9 -
 9+
1010 /**
1111 * Class for setting up the MediaWiki database using Postgres.
1212 *
Index: trunk/phase3/includes/Wiki.php
@@ -50,11 +50,11 @@
5151 */
5252 function performRequestForTitle( &$title, &$article, &$output, &$user, $request ) {
5353 wfProfileIn( __METHOD__ );
54 -
 54+
5555 $output->setTitle( $title );
56 -
 56+
5757 wfRunHooks( 'BeforeInitialize', array( &$title, &$article, &$output, &$user, $request, $this ) );
58 -
 58+
5959 if( !$this->preliminaryChecks( $title, $output, $request ) ) {
6060 wfProfileOut( __METHOD__ );
6161 return;
@@ -323,11 +323,11 @@
324324 {
325325 // Give extensions a change to ignore/handle redirects as needed
326326 $ignoreRedirect = $target = false;
327 -
 327+
328328 $dbr = wfGetDB( DB_SLAVE );
329329 $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) );
330330
331 - wfRunHooks( 'InitializeArticleMaybeRedirect',
 331+ wfRunHooks( 'InitializeArticleMaybeRedirect',
332332 array(&$title,&$request,&$ignoreRedirect,&$target,&$article) );
333333
334334 // Follow redirects only for... redirects.
Index: trunk/phase3/includes/DefaultSettings.php
@@ -73,7 +73,7 @@
7474 # If the port is a non-standard one, add it to the URL
7575 if( isset( $_SERVER['SERVER_PORT'] )
7676 && !strpos( $serverName, ':' )
77 - && ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 )
 77+ && ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 )
7878 || ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) {
7979
8080 $wgServer .= ":" . $_SERVER['SERVER_PORT'];
@@ -504,9 +504,9 @@
505505 * This is the list of preferred extensions for uploading files. Uploading files
506506 * with extensions not in this list will trigger a warning.
507507 *
508 - * WARNING: If you add any OpenOffice or Microsoft Office file formats here,
509 - * such as odt or doc, and untrusted users are allowed to upload files, then
510 - * your wiki will be vulnerable to cross-site request forgery (CSRF).
 508+ * WARNING: If you add any OpenOffice or Microsoft Office file formats here,
 509+ * such as odt or doc, and untrusted users are allowed to upload files, then
 510+ * your wiki will be vulnerable to cross-site request forgery (CSRF).
511511 */
512512 $wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg' );
513513
@@ -544,7 +544,7 @@
545545 'application/x-opc+zip',
546546 );
547547
548 -/**
 548+/**
549549 * This is a flag to determine whether or not to check file extensions on upload.
550550 *
551551 * WARNING: setting this to false is insecure for public wikis.
@@ -555,7 +555,7 @@
556556 * If this is turned off, users may override the warning for files not covered
557557 * by $wgFileExtensions.
558558 *
559 - * WARNING: setting this to false is insecure for public wikis.
 559+ * WARNING: setting this to false is insecure for public wikis.
560560 */
561561 $wgStrictFileExtensions = true;
562562
@@ -2300,7 +2300,7 @@
23012301 */
23022302
23032303 /**
2304 - * Client-side resource modules. Extensions should add their module definitions
 2304+ * Client-side resource modules. Extensions should add their module definitions
23052305 * here.
23062306 *
23072307 * Example:
@@ -2331,8 +2331,8 @@
23322332 );
23332333
23342334 /**
2335 - * Whether to embed private modules inline with HTML output or to bypass
2336 - * caching and check the user parameter against $wgUser to prevent
 2335+ * Whether to embed private modules inline with HTML output or to bypass
 2336+ * caching and check the user parameter against $wgUser to prevent
23372337 * unauthorized access to private modules.
23382338 */
23392339 $wgResourceLoaderInlinePrivateModules = true;
Index: trunk/phase3/includes/IP.php
@@ -599,7 +599,7 @@
600600 // IPv6 loopback address
601601 $m = array();
602602 if ( preg_match( '/^0*' . RE_IPV6_GAP . '1$/', $addr, $m ) ) {
603 - return '127.0.0.1';
 603+ return '127.0.0.1';
604604 }
605605 // IPv4-mapped and IPv4-compatible IPv6 addresses
606606 if ( preg_match( '/^' . RE_IPV6_V4_PREFIX . '(' . RE_IP_ADD . ')$/i', $addr, $m ) ) {

Status & tagging log