Followup r95921, clearer PHPDoc and better variable names per CR
authorJohn Du Hart <johnduhart@users.mediawiki.org>
Thu, 29 Sep 2011 20:21:32 +0000 (20:21 +0000)
committerJohn Du Hart <johnduhart@users.mediawiki.org>
Thu, 29 Sep 2011 20:21:32 +0000 (20:21 +0000)
includes/WebRequest.php

index 2abc3d2..84e7e78 100644 (file)
@@ -239,15 +239,18 @@ class WebRequest {
         * used for undoing the evil that is magic_quotes_gpc.
         *
         * @param $arr array: will be modified
-        * @param $recursion bool Used to modify behaviour based on recursion
+        * @param $topLevel bool Specifies if the array passed is from the top
+        * level of the source. In PHP5 magic_quotes only escapes the first level
+        * of keys that belong to an array.
         * @return array the original array
+        * @see http://www.php.net/manual/en/function.get-magic-quotes-gpc.php#49612
         */
-       private function &fix_magic_quotes( &$arr, $recursion = false ) {
+       private function &fix_magic_quotes( &$arr, $topLevel = true ) {
                $clean = array();
                foreach( $arr as $key => $val ) {
                        if( is_array( $val ) ) {
-                               $cleanKey = !$recursion ? stripslashes( $key ) : $key;
-                               $clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], true );
+                               $cleanKey = $topLevel ? stripslashes( $key ) : $key;
+                               $clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], false );
                        } else {
                                $cleanKey = stripslashes( $key );
                                $clean[$cleanKey] = stripslashes( $val );