r99926 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99925‎ | r99926 | r99927 >
Date:22:58, 15 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix whitespace, braces

Fix return items
Modified paths:
  • /trunk/phase3/img_auth.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/WikiPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBrokenRedirects.php (modified) (history)
  • /trunk/phase3/thumb.php (modified) (history)
  • /trunk/phase3/trackback.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -296,7 +296,7 @@
297297 static $needle;
298298 if ( is_null( $s ) ) {
299299 $needle = null;
300 - return;
 300+ return '';
301301 }
302302
303303 if ( is_null( $needle ) ) {
@@ -537,6 +537,7 @@
538538 * Like wfUrlProtocols(), but excludes '//' from the protocol list. Use this if
539539 * you need a regex that matches all URL protocols but does not match protocol-
540540 * relative URLs
 541+ * @return String
541542 */
542543 function wfUrlProtocolsWithoutProtRel() {
543544 return wfUrlProtocols( false );
@@ -960,6 +961,9 @@
961962 return (bool)$wgReadOnly;
962963 }
963964
 965+/**
 966+ * @return bool
 967+ */
964968 function wfReadOnlyReason() {
965969 global $wgReadOnly;
966970 wfReadOnly();
@@ -2888,6 +2892,7 @@
28892893 *
28902894 * @deprecated since 1.19
28912895 * @see DeferredUpdates::doUpdate()
 2896+ * @param $commit string
28922897 */
28932898 function wfDoUpdates( $commit = '' ) {
28942899 DeferredUpdates::doUpdates( $commit );
@@ -2985,6 +2990,7 @@
29862991 *
29872992 * @param $name String
29882993 * @param $p Array: parameters
 2994+ * @return object
29892995 * @deprecated since 1.18, warnings in 1.18, removal in 1.20
29902996 */
29912997 function wfCreateObject( $name, $p ) {
@@ -2992,6 +2998,9 @@
29932999 return MWFunction::newObj( $name, $p );
29943000 }
29953001
 3002+/**
 3003+ * @return bool
 3004+ */
29963005 function wfHttpOnlySafe() {
29973006 global $wgHttpOnlyBlacklist;
29983007
@@ -3122,7 +3131,6 @@
31233132 * Split a wiki ID into DB name and table prefix
31243133 *
31253134 * @param $wiki String
3126 - * @param $bits String
31273135 *
31283136 * @return array
31293137 */
@@ -3382,7 +3390,6 @@
33833391 *
33843392 * @param $maxLag Integer (deprecated)
33853393 * @param $wiki mixed Wiki identifier accepted by wfGetLB
3386 - * @return null
33873394 */
33883395 function wfWaitForSlaves( $maxLag = false, $wiki = false ) {
33893396 $lb = wfGetLB( $wiki );
@@ -3414,6 +3421,7 @@
34153422 * Count down from $n to zero on the terminal, with a one-second pause
34163423 * between showing each number. For use in command-line scripts.
34173424 * @codeCoverageIgnore
 3425+ * @param $n int
34183426 */
34193427 function wfCountDown( $n ) {
34203428 for ( $i = $n; $i >= 0; $i-- ) {
@@ -3522,7 +3530,7 @@
35233531 * See unit test for examples.
35243532 *
35253533 * @param $code String: The language code.
3526 - * @return $langCode String: The language code which complying with BCP 47 standards.
 3534+ * @return String: The language code which complying with BCP 47 standards.
35273535 */
35283536 function wfBCP47( $code ) {
35293537 $codeSegment = explode( '-', $code );
Index: trunk/phase3/includes/WikiPage.php
@@ -15,7 +15,6 @@
1616 class WikiPage extends Page {
1717 /**
1818 * @var Title
19 - * @protected
2019 */
2120 public $mTitle = null;
2221
Index: trunk/phase3/includes/specials/SpecialBrokenRedirects.php
@@ -22,7 +22,7 @@
2323 */
2424
2525 /**
26 - * A special page listing redirects tonon existent page. Those should be
 26+ * A special page listing redirects to non existent page. Those should be
2727 * fixed to point to an existing page.
2828 *
2929 * @ingroup SpecialPage
Index: trunk/phase3/trackback.php
@@ -26,6 +26,9 @@
2727 exit;
2828 }
2929
 30+ /**
 31+ * @param $err string
 32+ */
3033 private function XMLerror( $err = "Invalid request." ) {
3134 header( "HTTP/1.0 400 Bad Request" );
3235 header( "Content-Type: application/xml; charset=utf-8" );
Index: trunk/phase3/img_auth.php
@@ -50,8 +50,7 @@
5151 if ( $dotPos !== false ) {
5252 $whitelist[] = substr( $path, $dotPos + 1 );
5353 }
54 -if ( !$wgRequest->checkUrlExtension( $whitelist ) )
55 -{
 54+if ( !$wgRequest->checkUrlExtension( $whitelist ) ) {
5655 return;
5756 }
5857
@@ -59,38 +58,44 @@
6059 $realUpload = realpath( $wgUploadDirectory );
6160
6261 // Basic directory traversal check
63 -if( substr( $filename, 0, strlen( $realUpload ) ) != $realUpload )
 62+if( substr( $filename, 0, strlen( $realUpload ) ) != $realUpload ) {
6463 wfForbidden('img-auth-accessdenied','img-auth-notindir');
 64+}
6565
6666 // Extract the file name and chop off the size specifier
6767 // (e.g. 120px-Foo.png => Foo.png)
6868 $name = wfBaseName( $path );
69 -if( preg_match( '!\d+px-(.*)!i', $name, $m ) )
 69+if( preg_match( '!\d+px-(.*)!i', $name, $m ) ) {
7070 $name = $m[1];
 71+}
7172
7273 // Check to see if the file exists
73 -if( !file_exists( $filename ) )
 74+if( !file_exists( $filename ) ) {
7475 wfForbidden('img-auth-accessdenied','img-auth-nofile',$filename);
 76+}
7577
7678 // Check to see if tried to access a directory
77 -if( is_dir( $filename ) )
 79+if( is_dir( $filename ) ) {
7880 wfForbidden('img-auth-accessdenied','img-auth-isdir',$filename);
 81+}
7982
80 -
8183 $title = Title::makeTitleSafe( NS_FILE, $name );
8284
8385 // See if could create the title object
84 -if( !$title instanceof Title )
 86+if( !$title instanceof Title ) {
8587 wfForbidden('img-auth-accessdenied','img-auth-badtitle',$name);
 88+}
8689
8790 // Run hook
88 -if (!wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) )
 91+if (!wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) ) {
8992 wfForbidden($result[0],$result[1],array_slice($result,2));
 93+}
9094
9195 // Check user authorization for this title
9296 // UserCanRead Checks Whitelist too
93 -if( !$title->userCanRead() )
 97+if( !$title->userCanRead() ) {
9498 wfForbidden('img-auth-accessdenied','img-auth-noread',$name);
 99+}
95100
96101 // Stream the requested file
97102 wfDebugLog( 'img_auth', "Streaming `".$filename."`." );
@@ -101,16 +106,18 @@
102107 * Issue a standard HTTP 403 Forbidden header ($msg1-a message index, not a message) and an
103108 * error message ($msg2, also a message index), (both required) then end the script
104109 * subsequent arguments to $msg2 will be passed as parameters only for replacing in $msg2
 110+ * @param $msg1
 111+ * @param $msg2
105112 */
106 -function wfForbidden($msg1,$msg2) {
 113+function wfForbidden( $msg1, $msg2 ) {
107114 global $wgImgAuthDetails;
108115 $args = func_get_args();
109116 array_shift( $args );
110117 array_shift( $args );
111 - $MsgHdr = htmlspecialchars(wfMsg($msg1));
112 - $detailMsg = (htmlspecialchars(wfMsg(($wgImgAuthDetails ? $msg2 : 'badaccess-group0'),$args)));
113 - wfDebugLog('img_auth', "wfForbidden Hdr:".wfMsgExt( $msg1, array('language' => 'en'))." Msg: ".
114 - wfMsgExt($msg2,array('language' => 'en'),$args));
 118+ $MsgHdr = htmlspecialchars( wfMsg( $msg1 ) );
 119+ $detailMsg = ( htmlspecialchars( wfMsg( ( $wgImgAuthDetails ? $msg2 : 'badaccess-group0' ), $args ) ) );
 120+ wfDebugLog('img_auth', "wfForbidden Hdr:".wfMsgExt( $msg1, array( 'language' => 'en' ) )." Msg: ".
 121+ wfMsgExt( $msg2, array('language' => 'en' ), $args ) );
115122 header( 'HTTP/1.0 403 Forbidden' );
116123 header( 'Cache-Control: no-cache' );
117124 header( 'Content-Type: text/html; charset=utf-8' );
Index: trunk/phase3/thumb.php
@@ -75,7 +75,7 @@
7676 // Check permissions if there are read restrictions
7777 if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) {
7878 if ( !$img->getTitle()->userCanRead() ) {
79 - wfThumbError( 403, 'Access denied. You do not have permission to access ' .
 79+ wfThumbError( 403, 'Access denied. You do not have permission to access ' .
8080 'the source file.' );
8181 wfProfileOut( __METHOD__ );
8282 return;
@@ -162,6 +162,10 @@
163163 wfProfileOut( __METHOD__ );
164164 }
165165
 166+/**
 167+ * @param $status
 168+ * @param $msg
 169+ */
166170 function wfThumbError( $status, $msg ) {
167171 global $wgShowHostnames;
168172 header( 'Cache-Control: no-cache' );

Status & tagging log