wfSetRef doesn't work, making isWindows() function which I was going to use somewhere...
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 12 Jun 2004 06:05:02 +0000 (06:05 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 12 Jun 2004 06:05:02 +0000 (06:05 +0000)
includes/Database.php
includes/DatabasePostgreSQL.php
includes/GlobalFunctions.php

index 03b640f..d465c5e 100644 (file)
@@ -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 ); }
index 633f61d..80c762a 100644 (file)
@@ -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 ); }
index f51a5ee..a39c791 100644 (file)
@@ -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;
+       }
+}
+
 ?>