Make WordPress Core

Ticket #17884: 17884.4.diff

File 17884.4.diff, 2.5 KB (added by wonderboymusic, 11 years ago)
  • tests/phpunit/tests/basic.php

     
    8888EOF;
    8989                $this->assertEquals($expected, mask_input_value($in));
    9090        }
     91
     92        function test_setting_nonexistent_arrays() {
     93                $page = 1;
     94                $field = 'settings';
     95
     96                error_reporting( -1 );
     97
     98                $empty_array[$page][$field] = 'foo';
     99
     100                unset( $empty_array[$page]['bar']['baz'] );
     101        }
    91102}
  • src/wp-admin/includes/template.php

     
    10721072                $page = 'reading';
    10731073        }
    10741074
    1075         if ( !isset($wp_settings_sections) )
    1076                 $wp_settings_sections = array();
    1077         if ( !isset($wp_settings_sections[$page]) )
    1078                 $wp_settings_sections[$page] = array();
    1079         if ( !isset($wp_settings_sections[$page][$id]) )
    1080                 $wp_settings_sections[$page][$id] = array();
    1081 
    10821075        $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
    10831076}
    10841077
     
    11171110                $page = 'reading';
    11181111        }
    11191112
    1120         if ( !isset($wp_settings_fields) )
    1121                 $wp_settings_fields = array();
    1122         if ( !isset($wp_settings_fields[$page]) )
    1123                 $wp_settings_fields[$page] = array();
    1124         if ( !isset($wp_settings_fields[$page][$section]) )
    1125                 $wp_settings_fields[$page][$section] = array();
    1126 
    11271113        $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
    11281114}
    11291115
     
    11431129function do_settings_sections( $page ) {
    11441130        global $wp_settings_sections, $wp_settings_fields;
    11451131
    1146         if ( ! isset( $wp_settings_sections ) || !isset( $wp_settings_sections[$page] ) )
     1132        if ( ! isset( $wp_settings_sections[$page] ) )
    11471133                return;
    11481134
    11491135        foreach ( (array) $wp_settings_sections[$page] as $section ) {
     
    11781164function do_settings_fields($page, $section) {
    11791165        global $wp_settings_fields;
    11801166
    1181         if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
     1167        if ( ! isset( $wp_settings_fields[$page][$section] ) )
    11821168                return;
    11831169
    11841170        foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
     
    12191205function add_settings_error( $setting, $code, $message, $type = 'error' ) {
    12201206        global $wp_settings_errors;
    12211207
    1222         if ( !isset($wp_settings_errors) )
    1223                 $wp_settings_errors = array();
    1224 
    12251208        $new_error = array(
    12261209                'setting' => $setting,
    12271210                'code' => $code,