WordPress.org

Make WordPress Core

Changeset 6983


Ignore:
Timestamp:
02/22/2008 05:43:56 PM (10 years ago)
Author:
ryan
Message:

Notice fixes from nbachiyski. fixes #5961

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r6954 r6983  
    88    die('-1');
    99
    10 if ( 'ajax-tag-search' == $_GET['action'] ) {
     10if ( isset($_GET['action']) && 'ajax-tag-search' == $_GET['action'] ) {
    1111    if ( !current_user_can( 'manage_categories' ) )
    1212        die('-1');
     
    2121}
    2222
    23 $id = (int) $_POST['id'];
     23$id = isset($_POST['id'])? (int) $_POST['id'] : 0;
    2424switch ( $action = $_POST['action'] ) :
    2525case 'add-post' :
     
    166166    if ( 0 > $parent = (int) $_POST['newcat_parent'] )
    167167        $parent = 0;
    168 
    169     $checked_categories = array_map( 'absint', (array) $_POST['post_category'] );
     168    $post_category = isset($_POST['post_category'])? (array) $_POST['post_category'] : array();
     169    $checked_categories = array_map( 'absint', (array) $post_category );
    170170
    171171    $x = new WP_Ajax_Response();
  • trunk/wp-admin/edit-form-advanced.php

    r6969 r6983  
    11<?php
     2$action = isset($action)? $action : '';
    23if ( isset($_GET['message']) )
    34    $_GET['message'] = (int) $_GET['message'];
     
    1920<?php
    2021
    21 if (0 == $post_ID) {
     22if (!isset($post_ID) || 0 == $post_ID) {
    2223    $form_action = 'post';
    2324    $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
     
    137138}
    138139
    139 if ( ('edit' == $action) && current_user_can('delete_post', $post_ID) )
     140if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) )
    140141    echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$post_ID", 'delete-post_' . $post_ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete&nbsp;post') . "</a>";
    141142?>
  • trunk/wp-admin/edit-page-form.php

    r6969 r6983  
    11<?php
    22
    3 if (0 == $post_ID) {
     3if (!isset($post_ID) || 0 == $post_ID) {
    44    $form_action = 'post';
    55    $nonce_action = 'add-page';
  • trunk/wp-admin/includes/dashboard.php

    r6958 r6983  
    171171    global $wp_registered_widgets, $wp_registered_widget_controls;
    172172
     173    $sidebar_defaults = array('widget_id' => 0, 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '');
     174    extract( $sidebar_defaults, EXTR_PREFIX_ALL, 'sidebar' );
    173175    extract( $params[0], EXTR_PREFIX_ALL, 'sidebar' );
     176
     177    if ( !isset($wp_registered_widgets[$sidebar_widget_id]) || !is_array($wp_registered_widgets[$sidebar_widget_id]) ) {
     178        return $params;
     179    }
     180    $widget_defaults = array('id' => '', 'width' => '', 'height' => '', 'class' => '', 'feed_link' => '', 'all_link' => '', 'notice' => false, 'error' => false);
     181    extract( $widget_defaults, EXTR_PREFIX_ALL, 'widget' );
    174182    extract( $wp_registered_widgets[$sidebar_widget_id], EXTR_PREFIX_ALL, 'widget' );
    175183
  • trunk/wp-admin/includes/post.php

    r6955 r6983  
    2929    $_POST['post_content'] = $_POST['content'];
    3030    $_POST['post_excerpt'] = $_POST['excerpt'];
    31     $_POST['post_parent'] = $_POST['parent_id'];
     31    $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : '';
    3232    $_POST['to_ping'] = $_POST['trackback_url'];
    3333
     
    5353
    5454    // What to do based on which button they pressed
    55     if ('' != $_POST['saveasdraft'] )
     55    if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] )
    5656        $_POST['post_status'] = 'draft';
    57     if ('' != $_POST['saveasprivate'] )
     57    if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] )
    5858        $_POST['post_status'] = 'private';
    59     if ( ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) )
     59    if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) )
    6060        $_POST['post_status'] = 'publish';
    61     if ('' != $_POST['advanced'] )
     61    if ( isset($_POST['advanced']) && '' != $_POST['advanced'] )
    6262        $_POST['post_status'] = 'draft';
    6363
     
    9292
    9393    // Meta Stuff
    94     if ( $_POST['meta'] ) {
     94    if ( isset($_POST['meta']) && $_POST['meta'] ) {
    9595        foreach ( $_POST['meta'] as $key => $value )
    9696            update_meta( $key, $value['key'], $value['value'] );
    9797    }
    9898
    99     if ( $_POST['deletemeta'] ) {
     99    if ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {
    100100        foreach ( $_POST['deletemeta'] as $key => $value )
    101101            delete_meta( $key );
     
    129129    }
    130130
     131    $post_content = '';
    131132    if ( !empty( $_REQUEST['content'] ) )
    132133        $post_content = wp_specialchars( stripslashes( $_REQUEST['content'] ));
     
    143144        $post_excerpt = '';
    144145
     146    $post->ID = 0;
     147    $post->post_name = '';
     148    $post->post_author = '';
     149    $post->post_date = '';
    145150    $post->post_status = 'draft';
    146151    $post->post_type = 'post';
     152    $post->to_ping = '';
     153    $post->pinged = '';
    147154    $post->comment_status = get_option( 'default_comment_status' );
    148155    $post->ping_status = get_option( 'default_ping_status' );
     
    225232    $_POST['post_content'] = $_POST['content'];
    226233    $_POST['post_excerpt'] = $_POST['excerpt'];
    227     $_POST['post_parent'] = $_POST['parent_id'];
     234    $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : '';
    228235    $_POST['to_ping'] = $_POST['trackback_url'];
    229236
     
    251258
    252259    // What to do based on which button they pressed
    253     if ('' != $_POST['saveasdraft'] )
     260    if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] )
    254261        $_POST['post_status'] = 'draft';
    255     if ('' != $_POST['saveasprivate'] )
     262    if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] )
    256263        $_POST['post_status'] = 'private';
    257     if ( ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) )
     264    if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) )
    258265        $_POST['post_status'] = 'publish';
    259     if ('' != $_POST['advanced'] )
     266    if ( isset($_POST['advanced']) && '' != $_POST['advanced'] )
    260267        $_POST['post_status'] = 'draft';
    261268
     
    572579function get_sample_permalink($id, $name = null) {
    573580    $post = &get_post($id);
     581    if (!$post->ID) {
     582        return array('', '');
     583    }
    574584    $original_status = $post->post_status;
    575585    $original_date = $post->post_date;
  • trunk/wp-admin/includes/taxonomy.php

    r6588 r6983  
    5252
    5353function wp_insert_category($catarr, $wp_error = false) {
     54    $cat_defaults = array('cat_ID' => 0, 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
    5455    extract($catarr, EXTR_SKIP);
    5556
  • trunk/wp-admin/media-upload.php

    r6659 r6983  
    1212
    1313// IDs should be integers
    14 $ID = (int) $ID;
    15 $post_id = (int) $post_id;
     14$ID = isset($ID)? (int) $ID : 0;
     15$post_id = isset($post_id)? (int) $post_id : 0;
    1616
    1717// Require an ID for the edit screen
    18 if ( $action == 'edit' && !$ID )
     18if ( isset($action) && $action == 'edit' && !$ID )
    1919    wp_die(__("You are not allowed to be here"));
    2020
  • trunk/wp-admin/post.php

    r6894 r6983  
    128128        $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
    129129
    130         if ($_POST['addmeta']) {
     130        if (isset($_POST['addmeta']) && $_POST['addmeta']) {
    131131            $location = add_query_arg( 'message', 2, wp_get_referer() );
    132132            $location = explode('#', $location);
    133133            $location = $location[0] . '#postcustom';
    134         } elseif ($_POST['deletemeta']) {
     134        } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
    135135            $location = add_query_arg( 'message', 3, wp_get_referer() );
    136136            $location = explode('#', $location);
  • trunk/wp-includes/canonical.php

    r6743 r6983  
    179179        $redirect['host'] = $original['host'];
    180180
     181    // prevent notices in the comparison below
     182    $original['query'] = isset($redirect['query'])? $redirect['query'] : false;
     183    $original['port'] = isset($redirect['port'])? $redirect['port'] : false;
     184    $redirect['query'] = isset($redirect['query'])? $redirect['query'] : false;
     185    $redirect['port'] = isset($redirect['port'])? $redirect['port'] : false;
     186
    181187    if ( array($original['host'], $original['port'], $original['path'], $original['query']) !== array($redirect['host'], $redirect['port'], $redirect['path'], $redirect['query']) ) {
    182188        $redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
  • trunk/wp-includes/functions.php

    r6817 r6983  
    376376    // expected_slashed ($name)
    377377    $option = $wpdb->get_row( "SELECT option_id, autoload FROM $wpdb->options WHERE option_name = '$name'" );
    378     if ( !$option->option_id )
     378    if ( is_null($option) || !$option->option_id )
    379379        return false;
    380380    // expected_slashed ($name)
  • trunk/wp-includes/post.php

    r6974 r6983  
    181181        return $_post;
    182182    } elseif ( $output == ARRAY_A ) {
    183         return get_object_vars($_post);
     183        $__post = get_object_vars($_post);
     184        return $__post;
    184185    } elseif ( $output == ARRAY_N ) {
    185         return array_values(get_object_vars($_post));
     186        $__post = array_values(get_object_vars($_post));
     187        return $__post;
    186188    } else {
    187189        return $_post;
     
    699701    if ( 'raw' == $context )
    700702        return $post;
    701 
    702     if ( is_object($post) )
     703    if ( is_object($post) ) {
     704        if ( !isset($post->ID) )
     705            return $post;
    703706        foreach ( array_keys(get_object_vars($post)) as $field )
    704707            $post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
    705     else
     708    } else {
     709        if ( !isset($post['ID']) )
     710            return $post;
    706711        foreach ( array_keys($post) as $field )
    707712            $post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
    708 
     713    }
    709714    return $post;
    710715}
     
    23672372 */
    23682373function wp_check_for_changed_slugs($post_id) {
    2369     if ( !strlen($_POST['wp-old-slug']) )
     2374    if ( !isset($_POST['wp-old-slug']) || !strlen($_POST['wp-old-slug']) )
    23702375        return $post_id;
    23712376
  • trunk/wp-includes/query.php

    r6910 r6983  
    11551155        // MIME-Type stuff for attachment browsing
    11561156
    1157         if ( '' != $q['post_mime_type'] )
     1157        if ( isset($q['post_mime_type']) && '' != $q['post_mime_type'] )
    11581158            $whichmimetype = wp_post_mime_type_where($q['post_mime_type']);
    11591159
  • trunk/wp-includes/taxonomy.php

    r6851 r6983  
    641641    }
    642642
     643    $select_this = '';
    643644    if ( 'all' == $fields )
    644645        $select_this = 't.*, tt.*';
     
    10421043    $object_ids = implode(', ', $object_ids);
    10431044
     1045    $select_this = '';
    10441046    if ( 'all' == $fields )
    10451047        $select_this = 't.*, tt.*';
     
    12531255
    12541256    $t = get_taxonomy($taxonomy);
    1255     if ( ! $append && $t->sort ) {
     1257    if ( ! $append && isset($t->sort) && $t->sort ) {
    12561258        $values = array();
    12571259        $term_order = 0;
  • trunk/wp-includes/widgets.php

    r6861 r6983  
    260260    if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $sidebar => $widgets )
    261261        if ( is_array($widgets) ) foreach ( $widgets as $widget )
    262             if ( $wp_registered_widgets[$widget]['callback'] == $callback )
     262            if ( isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback )
    263263                return $sidebar;
    264264
Note: See TracChangeset for help on using the changeset viewer.