r31327 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31326‎ | r31327 | r31328 >
Date:22:33, 26 February 2008
Author:brion
Status:old
Tags:
Comment:
* (bug 13139, 13074) Fix request data for parameters with numeric names
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1980,6 +1980,28 @@
19811981 }
19821982
19831983 /**
 1984+ * array_merge() does awful things with "numeric" indexes, including
 1985+ * string indexes when happen to look like integers. When we want
 1986+ * to merge arrays with arbitrary string indexes, we don't want our
 1987+ * arrays to be randomly corrupted just because some of them consist
 1988+ * of numbers.
 1989+ *
 1990+ * Fuck you, PHP. Fuck you in the ear!
 1991+ *
 1992+ * @param array $array1, [$array2, [...]]
 1993+ * @return array
 1994+ */
 1995+function wfArrayMerge( $array1/* ... */ ) {
 1996+ $out = $array1;
 1997+ for( $i = 1; $i < func_num_args(); $i++ ) {
 1998+ foreach( func_get_arg( $i ) as $key => $value ) {
 1999+ $out[$key] = $value;
 2000+ }
 2001+ }
 2002+ return $out;
 2003+}
 2004+
 2005+/**
19842006 * Make a URL index, appropriate for the el_index field of externallinks.
19852007 */
19862008 function wfMakeUrlIndex( $url ) {
Index: trunk/phase3/includes/WebRequest.php
@@ -54,7 +54,7 @@
5555
5656 // POST overrides GET data
5757 // We don't use $_REQUEST here to avoid interference from cookies...
58 - $this->data = array_merge( $_GET, $_POST );
 58+ $this->data = wfArrayMerge( $_GET, $_POST );
5959 }
6060
6161 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r31331Merge fixes from trunk:...brion22:53, 26 February 2008
r43041Update doc comment for wfArrayMerge() to note the behavior difference between...brion22:30, 1 November 2008

Status & tagging log