r85800 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85799‎ | r85800 | r85801 >
Date:16:49, 11 April 2011
Author:pcopp
Status:ok
Tags:
Comment:
Fix some Notices:
* LanguageKaa.php: Fix ucfirst and lcfirst for empty strings.
* SkinTemplate.php: Fix undefined array access.
* ProxyTools.php: When running hiphop in cli mode, apache_request_headers() returns null. Fix wfGetForwardedFor() to account for that.
Modified paths:
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/languages/classes/LanguageKaa.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProxyTools.php
@@ -12,10 +12,11 @@
1313 * @return string
1414 */
1515 function wfGetForwardedFor() {
16 - if( function_exists( 'apache_request_headers' ) ) {
 16+ $apacheHeaders = function_exists( 'apache_request_headers' ) ? apache_request_headers() : null;
 17+ if( is_array( $apacheHeaders ) ) {
1718 // More reliable than $_SERVER due to case and -/_ folding
1819 $set = array ();
19 - foreach ( apache_request_headers() as $tempName => $tempValue ) {
 20+ foreach ( $apacheHeaders as $tempName => $tempValue ) {
2021 $set[ strtoupper( $tempName ) ] = $tempValue;
2122 }
2223 $index = strtoupper ( 'X-Forwarded-For' );
Index: trunk/phase3/includes/SkinTemplate.php
@@ -1461,15 +1461,16 @@
14621462 $toolbox['print']['rel'] = 'alternate';
14631463 $toolbox['print']['msg'] = 'printableversion';
14641464 }
1465 - if ( !empty( $this->data['nav_urls']['permalink']['href'] ) ) {
 1465+ if( $this->data['nav_urls']['permalink'] ) {
14661466 $toolbox['permalink'] = $this->data['nav_urls']['permalink'];
1467 - $toolbox['permalink']['id'] = 't-permalink';
1468 - } elseif ( $this->data['nav_urls']['permalink']['href'] === '' ) {
1469 - $toolbox['permalink'] = $this->data['nav_urls']['permalink'];
1470 - unset( $toolbox['permalink']['href'] );
1471 - $toolbox['ispermalink']['tooltiponly'] = true;
1472 - $toolbox['ispermalink']['id'] = 't-ispermalink';
1473 - $toolbox['ispermalink']['msg'] = 'permalink';
 1467+ if( $toolbox['permalink']['href'] === '' ) {
 1468+ unset( $toolbox['permalink']['href'] );
 1469+ $toolbox['ispermalink']['tooltiponly'] = true;
 1470+ $toolbox['ispermalink']['id'] = 't-ispermalink';
 1471+ $toolbox['ispermalink']['msg'] = 'permalink';
 1472+ } else {
 1473+ $toolbox['permalink']['id'] = 't-permalink';
 1474+ }
14741475 }
14751476 wfRunHooks( 'BaseTemplateToolbox', array( &$this, &$toolbox ) );
14761477 wfProfileOut( __METHOD__ );
Index: trunk/phase3/languages/classes/LanguageKaa.php
@@ -24,13 +24,11 @@
2525 *
2626 */
2727 function ucfirst ( $string ) {
28 - if ( $string[0] == 'i' ) {
29 - $string = 'İ' . substr( $string, 1 );
 28+ if ( substr( $string, 0, 1 ) === 'i' ) {
 29+ return 'İ' . substr( $string, 1 );
3030 } else {
31 - $string = parent::ucfirst( $string );
 31+ return parent::ucfirst( $string );
3232 }
33 - return $string;
34 -
3533 }
3634
3735 /*
@@ -38,12 +36,11 @@
3937 *
4038 */
4139 function lcfirst ( $string ) {
42 - if ( $string[0] == 'I' ) {
43 - $string = 'ı' . substr( $string, 1 );
 40+ if ( substr( $string, 0, 1 ) === 'I' ) {
 41+ return 'ı' . substr( $string, 1 );
4442 } else {
45 - $string = parent::lcfirst( $string );
 43+ return parent::lcfirst( $string );
4644 }
47 - return $string;
4845 }
4946
5047 /**

Status & tagging log