From 82cd975e9e0faba9e96b201293efd8757a2ad75e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 26 Feb 2008 22:33:04 +0000 Subject: [PATCH] * (bug 13139, 13074) Fix request data for parameters with numeric names --- includes/GlobalFunctions.php | 22 ++++++++++++++++++++++ includes/WebRequest.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 286a9b80d4..7fddfed664 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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. */ diff --git a/includes/WebRequest.php b/includes/WebRequest.php index fd8acc533c..e2075c97e4 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -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 ); } /** -- 2.20.1