Make WordPress Core

Ticket #4571: fix_option_parsing.diff

File fix_option_parsing.diff, 2.1 KB (added by m0n5t3r, 16 years ago)

patch to address the issue

  • wp-includes/compat.php

     
    125125        }
    126126}
    127127
     128//added in PHP 5.0
     129if(!function_exists("array_walk_recursive")){
     130        /**
     131         * taken from php.net
     132         */
     133        function array_walk_recursive(&$input, $funcname, $userdata = '') {
     134                if(!is_callable($funcname))
     135                        return false;
     136
     137                if(!is_array($input))
     138                        return false;
     139
     140                foreach($input as $key=>$value) {
     141                        if(is_array($input[$key])) {
     142                                if(isset($this)) {
     143                                        eval('$this->' . __FUNCTION__ . '($input[$key], $funcname, $userdata);');
     144                                } else {
     145                                        if(@get_class($this))
     146                                                eval(get_class() . '::' . __FUNCTION__ . '($input[$key], $funcname, $userdata);');
     147                                        else
     148                                                eval(__FUNCTION__ . '($input[$key], $funcname, $userdata);');
     149                                }
     150                        } else {
     151                                $saved_value = $value;
     152
     153                                if(is_array($funcname)) {
     154                                        $f = '';
     155                                        for($a=0; $a<count($funcname); $a++)
     156                                                if(is_object($funcname[$a])) {
     157                                                        $f .= get_class($funcname[$a]);
     158                                                } else {
     159                                                        if($a > 0)
     160                                                                $f .= '::';
     161                                                        $f .= $funcname[$a];
     162                                                }
     163                                        $f .= '($value, $key' . (!empty($userdata) ? ', $userdata' : '') . ');';
     164                                        eval($f);
     165                                } else {
     166                                        if(!empty($userdata))
     167                                                $funcname($value, $key, $userdata);
     168                                        else
     169                                                $funcname($value, $key);
     170                                }
     171
     172                                if($value != $saved_value)
     173                                        $input[$key] = $value;
     174                        }
     175                }
     176                return true;
     177        }
     178}
     179
    128180?>
  • wp-admin/options.php

     
    2929        if ($options) {
    3030                foreach ($options as $option) {
    3131                        $option = trim($option);
    32                         $value = trim($_POST[$option]);
    33                         $value = stripslashes($value);
     32                        if(is_string($_POST[$option])){
     33                                $value = trim($_POST[$option]);
     34                                $value = stripslashes($value);
     35                        } else {
     36                                $value = $_POST[$option];
     37                                array_walk_recursive("trim", $value);
     38                                array_walk_recursive("stripslashes", $value);
     39                        }
    3440                        update_option($option, $value);
    3541                }
    3642        }