From 19a1e9682b9f637196d3dd20d89e9ff4f42fcc89 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 25 Aug 2008 21:50:11 +0000 Subject: [PATCH] Notice fixes. see #7509 git-svn-id: http://svn.automattic.com/wordpress/trunk@8732 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 5 +++-- wp-admin/includes/post.php | 7 ++++--- wp-admin/includes/template.php | 30 ++++++++++++++++-------------- wp-admin/revision.php | 2 +- wp-includes/canonical.php | 10 ++++++---- wp-includes/post.php | 17 +++++++++++++---- wp-includes/taxonomy.php | 6 ++++-- 7 files changed, 47 insertions(+), 30 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 59b1c6903f..258a3f78d2 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -13,6 +13,8 @@ */ if ( ! isset( $post_ID ) ) $post_ID = 0; +else + $post_ID = (int) $post_ID; $action = isset($action) ? $action : ''; if ( isset($_GET['message']) ) @@ -36,10 +38,9 @@ if ( 0 == $post_ID ) { $form_extra = ""; $autosave = false; } else { - $post_ID = (int) $post_ID; $form_action = 'editpost'; $form_extra = ""; - $autosave = wp_get_post_autosave( $post_id ); + $autosave = wp_get_post_autosave( $post_ID ); // Detect if there exists an autosave newer than the post and if that autosave is different than the post if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) { diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index a48e575b85..4e83a1a6c6 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -17,7 +17,8 @@ function _wp_translate_postdata( $update = false ) { $_POST['post_content'] = $_POST['content']; $_POST['post_excerpt'] = $_POST['excerpt']; $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : ''; - $_POST['to_ping'] = $_POST['trackback_url']; + if ( isset($_POST['trackback_url']) ) + $_POST['to_ping'] = $_POST['trackback_url']; if (!empty ( $_POST['post_author_override'] ) ) { $_POST['post_author'] = (int) $_POST['post_author_override']; @@ -29,7 +30,7 @@ function _wp_translate_postdata( $update = false ) { } } - if ( $_POST['post_author'] != $_POST['user_ID'] ) { + if ( isset($_POST['user_ID']) && ($_POST['post_author'] != $_POST['user_ID']) ) { if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_others_pages' ) ) { return new WP_Error( 'edit_others_pages', $update ? @@ -66,7 +67,7 @@ function _wp_translate_postdata( $update = false ) { if ( $previous_status != 'publish' OR !current_user_can( 'edit_published_pages') ) $_POST['post_status'] = 'pending'; } else { - if ( 'publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) ) : + if ( isset($_POST['post_status']) && ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' )) ) : // Stop attempts to publish new posts, but allow already published posts to be saved if appropriate. if ( $previous_status != 'publish' OR !current_user_can( 'edit_published_posts') ) $_POST['post_status'] = 'pending'; diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 8e19eca536..4e05c746df 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -917,7 +917,7 @@ function user_row( $user_object, $style = '', $role = '' ) { } else { $edit = $user_object->user_login; } - $role_name = $wp_roles->role_names[$role] ? translate_with_context($wp_roles->role_names[$role]) : __('None'); + $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None'); $r = " $edit @@ -1530,19 +1530,21 @@ function do_meta_boxes($page, $context, $object) { break; foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) { - foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { - if ( false == $box || ! $box['title'] ) - continue; - $i++; - $style = ''; - if ( in_array($box['id'], $hidden) ) - $style = 'style="display:none;"'; - echo '
' . "\n"; - echo "

{$box['title']}

\n"; - echo '
' . "\n"; - call_user_func($box['callback'], $object, $box); - echo "
\n"; - echo "
\n"; + if ( isset($wp_meta_boxes[$page][$context][$priority]) ) { + foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { + if ( false == $box || ! $box['title'] ) + continue; + $i++; + $style = ''; + if ( in_array($box['id'], $hidden) ) + $style = 'style="display:none;"'; + echo '
' . "\n"; + echo "

{$box['title']}

\n"; + echo '
' . "\n"; + call_user_func($box['callback'], $object, $box); + echo "
\n"; + echo "
\n"; + } } } } while(0); diff --git a/wp-admin/revision.php b/wp-admin/revision.php index 3b21e72471..c93357cc36 100644 --- a/wp-admin/revision.php +++ b/wp-admin/revision.php @@ -9,7 +9,7 @@ /** WordPress Administration Bootstrap */ require_once('admin.php'); -wp_reset_vars(array('revision', 'left', 'right', 'action')); +wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action')); $revision_id = absint($revision); $diff = absint($diff); $left = absint($left); diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 1671b44285..c23cbfbe02 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -156,11 +156,13 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { // Remove trailing spaces from the path $redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] ); - // Remove trailing slashes from certain terminating query string args - $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] ); + if ( isset( $redirect['query'] ) ) { + // Remove trailing slashes from certain terminating query string args + $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] ); - // Clean up empty query strings - $redirect['query'] = preg_replace( '#&?(p|page_id|cat|tag)=?$#', '', $redirect['query'] ); + // Clean up empty query strings + $redirect['query'] = preg_replace( '#&?(p|page_id|cat|tag)=?$#', '', $redirect['query'] ); + } // strip /index.php/ when we're not using PATHINFO permalinks if ( !$wp_rewrite->using_index_permalinks() ) diff --git a/wp-includes/post.php b/wp-includes/post.php index ee9362a4a9..3da3999f7d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -123,8 +123,10 @@ function &get_children($args = '', $output = OBJECT) { $r = wp_parse_args( $args, $defaults ); $children = get_posts( $r ); - if ( !$children ) - return false; + if ( !$children ) { + $kids = false; + return $kids; + } update_post_cache($children); @@ -776,9 +778,13 @@ function sanitize_post($post, $context = 'display') { if ( 'raw' == $context ) return $post; if ( is_object($post) ) { + if ( !isset($post->ID) ) + $post->ID = 0; foreach ( array_keys(get_object_vars($post)) as $field ) $post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context); } else { + if ( !isset($post['ID']) ) + $post['ID'] = 0; foreach ( array_keys($post) as $field ) $post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context); } @@ -1316,7 +1322,7 @@ function wp_insert_post($postarr = array(), $wp_error = false) { } // Make sure we set a valid category - if (0 == count($post_category) || !is_array($post_category)) { + if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) { $post_category = array(get_option('default_category')); } @@ -1329,6 +1335,8 @@ function wp_insert_post($postarr = array(), $wp_error = false) { if ( empty($post_type) ) $post_type = 'post'; + $post_ID = 0; + // Get the post ID and GUID if ( $update ) { $post_ID = (int) $ID; @@ -1432,7 +1440,8 @@ function wp_insert_post($postarr = array(), $wp_error = false) { return 0; } } else { - $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update + if ( isset($post_mime_type) ) + $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update if ( false === $wpdb->insert( $wpdb->posts, $data ) ) { if ( $wp_error ) return new WP_Error('db_insert_error', __('Could not insert post into the database'), $wpdb->last_error); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 684d5aa376..fc39a7c436 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -609,8 +609,10 @@ function &get_terms($taxonomies, $args = '') { $key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key ); if ( $cache = wp_cache_get( 'get_terms', 'terms' ) ) { - if ( isset( $cache[ $key ] ) ) - return apply_filters('get_terms', $cache[$key], $taxonomies, $args); + if ( isset( $cache[ $key ] ) ) { + $terms = apply_filters('get_terms', $cache[$key], $taxonomies, $args); + return $terms; + } } if ( 'count' == $orderby )