From 49749f309129c5615996446a7b9037dbf072cb43 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 12 Jun 2004 06:05:02 +0000 Subject: [PATCH] wfSetRef doesn't work, making isWindows() function which I was going to use somewhere else but decided against it --- includes/Database.php | 2 +- includes/DatabasePostgreSQL.php | 2 +- includes/GlobalFunctions.php | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 03b640fa9e..d465c5e38d 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -39,7 +39,7 @@ class Database { # Output page, used for reporting errors # FALSE means discard output - function &setOutputPage( &$out ) { return wfSetRef( $this->mOut, $out ); } + function &setOutputPage( &$out ) { $this->mOut =& $out; } # Boolean, controls output of large amounts of debug information function setDebug( $debug ) { return wfSetVar( $this->mDebug, $debug ); } diff --git a/includes/DatabasePostgreSQL.php b/includes/DatabasePostgreSQL.php index 633f61d5b9..80c762ad3c 100644 --- a/includes/DatabasePostgreSQL.php +++ b/includes/DatabasePostgreSQL.php @@ -52,7 +52,7 @@ class Database { # Output page, used for reporting errors # FALSE means discard output - function &setOutputPage( &$out ) { return wfSetRef( $this->mOut, $out ); } + function &setOutputPage( &$out ) { $this->mOut =& $out; } # Boolean, controls output of large amounts of debug information function setDebug( $debug ) { return wfSetVar( $this->mDebug, $debug ); } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index f51a5ee3e2..a39c79147a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -164,6 +164,7 @@ function wfUtf8Sequence($codepoint) { return "&#$codepoint;"; } +# Converts numeric character entities to UTF-8 function wfMungeToUtf8($string) { global $wgInputEncoding; # This is debatable #$string = iconv($wgInputEncoding, "UTF-8", $string); @@ -716,11 +717,10 @@ function wfSetVar( &$dest, $source ) } # Sets dest to a reference to source and returns the original dest +# Pity that doesn't work in PHP function &wfSetRef( &$dest, &$source ) { - $temp =& $dest; - $dest =& $source; - return $temp; + die( "You can't rebind a variable in the caller's scope" ); } # This function takes two arrays as input, and returns a CGI-style string, e.g. @@ -762,7 +762,7 @@ function wfEscapeShellArg( ) $first = false; } - if (substr(php_uname(), 0, 7) == 'Windows') { + if ( isWindows() ) { $retVal .= '"' . str_replace( '"','\"', $arg ) . '"'; } else { $retVal .= escapeshellarg( $arg ); @@ -935,4 +935,14 @@ function wfArrayLookup( $a, $b ) return array_flip( array_intersect( array_flip( $a ), array_keys( $b ) ) ); } +# Since Windows is so different to any of the other popular OSes, it seems appropriate +# to have a simple way to test for its presence +function wfIsWindows() { + if (substr(php_uname(), 0, 7) == 'Windows') { + return true; + } else { + return false; + } +} + ?> -- 2.20.1