* (bug 13139, 13074) Fix request data for parameters with numeric names
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 26 Feb 2008 22:33:04 +0000 (22:33 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 26 Feb 2008 22:33:04 +0000 (22:33 +0000)
includes/GlobalFunctions.php
includes/WebRequest.php

index 286a9b8..7fddfed 100644 (file)
@@ -1979,6 +1979,28 @@ function wfRelativePath( $path, $from ) {
        return implode( DIRECTORY_SEPARATOR, $pieces );
 }
 
+/**
+ * array_merge() does awful things with "numeric" indexes, including
+ * string indexes when happen to look like integers. When we want
+ * to merge arrays with arbitrary string indexes, we don't want our
+ * arrays to be randomly corrupted just because some of them consist
+ * of numbers.
+ *
+ * Fuck you, PHP. Fuck you in the ear!
+ *
+ * @param array $array1, [$array2, [...]]
+ * @return array
+ */
+function wfArrayMerge( $array1/* ... */ ) {
+       $out = $array1;
+       for( $i = 1; $i < func_num_args(); $i++ ) {
+               foreach( func_get_arg( $i ) as $key => $value ) {
+                       $out[$key] = $value;
+               }
+       }
+       return $out;
+}
+
 /**
  * Make a URL index, appropriate for the el_index field of externallinks.
  */
index fd8acc5..e2075c9 100644 (file)
@@ -54,7 +54,7 @@ class WebRequest {
                
                // POST overrides GET data
                // We don't use $_REQUEST here to avoid interference from cookies...
-               $this->data = array_merge( $_GET, $_POST );
+               $this->data = wfArrayMerge( $_GET, $_POST );
        }
        
        /**