* 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.
* @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' );
$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__ );
*
*/
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;
-
}
/*
*
*/
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;
}
/**