From: Paul Copperman Date: Mon, 11 Apr 2011 16:49:36 +0000 (+0000) Subject: Fix some Notices: X-Git-Tag: 1.31.0-rc.0~30933 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=efb8c6b899ae1ef2f683319989876a0ab6d29431;p=lhc%2Fweb%2Fwiklou.git 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. --- diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index 13c199654d..c09403ab2f 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -12,10 +12,11 @@ * @return string */ function wfGetForwardedFor() { - if( function_exists( 'apache_request_headers' ) ) { + $apacheHeaders = function_exists( 'apache_request_headers' ) ? apache_request_headers() : null; + if( is_array( $apacheHeaders ) ) { // More reliable than $_SERVER due to case and -/_ folding $set = array (); - foreach ( apache_request_headers() as $tempName => $tempValue ) { + foreach ( $apacheHeaders as $tempName => $tempValue ) { $set[ strtoupper( $tempName ) ] = $tempValue; } $index = strtoupper ( 'X-Forwarded-For' ); diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 3b39abea20..e5cfe2f239 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -1461,15 +1461,16 @@ abstract class BaseTemplate extends QuickTemplate { $toolbox['print']['rel'] = 'alternate'; $toolbox['print']['msg'] = 'printableversion'; } - if ( !empty( $this->data['nav_urls']['permalink']['href'] ) ) { + if( $this->data['nav_urls']['permalink'] ) { $toolbox['permalink'] = $this->data['nav_urls']['permalink']; - $toolbox['permalink']['id'] = 't-permalink'; - } elseif ( $this->data['nav_urls']['permalink']['href'] === '' ) { - $toolbox['permalink'] = $this->data['nav_urls']['permalink']; - unset( $toolbox['permalink']['href'] ); - $toolbox['ispermalink']['tooltiponly'] = true; - $toolbox['ispermalink']['id'] = 't-ispermalink'; - $toolbox['ispermalink']['msg'] = 'permalink'; + if( $toolbox['permalink']['href'] === '' ) { + unset( $toolbox['permalink']['href'] ); + $toolbox['ispermalink']['tooltiponly'] = true; + $toolbox['ispermalink']['id'] = 't-ispermalink'; + $toolbox['ispermalink']['msg'] = 'permalink'; + } else { + $toolbox['permalink']['id'] = 't-permalink'; + } } wfRunHooks( 'BaseTemplateToolbox', array( &$this, &$toolbox ) ); wfProfileOut( __METHOD__ ); diff --git a/languages/classes/LanguageKaa.php b/languages/classes/LanguageKaa.php index 4c6710ed5b..8fa5b47444 100644 --- a/languages/classes/LanguageKaa.php +++ b/languages/classes/LanguageKaa.php @@ -24,13 +24,11 @@ class LanguageKaa extends Language { * */ function ucfirst ( $string ) { - if ( $string[0] == 'i' ) { - $string = 'İ' . substr( $string, 1 ); + if ( substr( $string, 0, 1 ) === 'i' ) { + return 'İ' . substr( $string, 1 ); } else { - $string = parent::ucfirst( $string ); + return parent::ucfirst( $string ); } - return $string; - } /* @@ -38,12 +36,11 @@ class LanguageKaa extends Language { * */ function lcfirst ( $string ) { - if ( $string[0] == 'I' ) { - $string = 'ı' . substr( $string, 1 ); + if ( substr( $string, 0, 1 ) === 'I' ) { + return 'ı' . substr( $string, 1 ); } else { - $string = parent::lcfirst( $string ); + return parent::lcfirst( $string ); } - return $string; } /**