SiteConfiguration was smashing all variables into strings (or arrays of strings)...
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 19 Jan 2008 06:06:49 +0000 (06:06 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 19 Jan 2008 06:06:49 +0000 (06:06 +0000)
This broke on things that wanted an actual 'false' or 'null' value exactly (or ints, though haven't run across such).
Changed to a type-safe replace that only does replaces on strings and strings in subarrays

includes/SiteConfiguration.php

index 353f5b3..e124183 100644 (file)
@@ -36,11 +36,25 @@ class SiteConfiguration {
 
                if ( !is_null( $retval ) && count( $params ) ) {
                        foreach ( $params as $key => $value ) {
-                               $retval = str_replace( '$' . $key, $value, $retval );
+                               $retval = $this->doReplace( '$' . $key, $value, $retval );
                        }
                }
                return $retval;
        }
+       
+       /** Type-safe string replace; won't do replacements on non-strings */
+       function doReplace( $from, $to, $in ) {
+               if( is_string( $in ) ) {
+                       return str_replace( $from, $to, $in );
+               } elseif( is_array( $in ) ) {
+                       foreach( $in as $key => $val ) {
+                               $in[$key] = $this->doReplace( $from, $to, $in );
+                       }
+                       return $in;
+               } else {
+                       return $in;
+               }
+       }
 
        /** */
        function getAll( $wiki, $suffix, $params ) {