Fix some Notices:
authorPaul Copperman <pcopp@users.mediawiki.org>
Mon, 11 Apr 2011 16:49:36 +0000 (16:49 +0000)
committerPaul Copperman <pcopp@users.mediawiki.org>
Mon, 11 Apr 2011 16:49:36 +0000 (16:49 +0000)
* 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.

includes/ProxyTools.php
includes/SkinTemplate.php
languages/classes/LanguageKaa.php

index 13c1996..c09403a 100644 (file)
  * @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' );
index 3b39abe..e5cfe2f 100644 (file)
@@ -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__ );
index 4c6710e..8fa5b47 100644 (file)
@@ -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;
        }
 
        /**