Notice fixes. see #7509

git-svn-id: http://svn.automattic.com/wordpress/trunk@8732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-08-25 21:50:11 +00:00
parent 37d88adaff
commit 19a1e9682b
7 changed files with 47 additions and 30 deletions

View File

@ -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 = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
$autosave = false;
} else {
$post_ID = (int) $post_ID;
$form_action = 'editpost';
$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
$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 ) ) {

View File

@ -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';

View File

@ -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 = "<tr id='user-$user_object->ID'$style>
<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>
<td><strong>$edit</strong></td>
@ -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 '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
echo "<h3><span class='hndle'>{$box['title']}</span></h3>\n";
echo '<div class="inside">' . "\n";
call_user_func($box['callback'], $object, $box);
echo "</div>\n";
echo "</div>\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 '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
echo "<h3><span class='hndle'>{$box['title']}</span></h3>\n";
echo '<div class="inside">' . "\n";
call_user_func($box['callback'], $object, $box);
echo "</div>\n";
echo "</div>\n";
}
}
}
} while(0);

View File

@ -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);

View File

@ -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() )

View File

@ -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);

View File

@ -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 )