Notice fixes from nbachiyski. fixes #5961

git-svn-id: http://svn.automattic.com/wordpress/trunk@6983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-02-22 17:43:56 +00:00
parent 54f091eebf
commit dce0978cee
14 changed files with 70 additions and 37 deletions

View File

@@ -178,6 +178,12 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
if ( strtolower($original['host']) == strtolower($redirect['host']) )
$redirect['host'] = $original['host'];
// prevent notices in the comparison below
$original['query'] = isset($redirect['query'])? $redirect['query'] : false;
$original['port'] = isset($redirect['port'])? $redirect['port'] : false;
$redirect['query'] = isset($redirect['query'])? $redirect['query'] : false;
$redirect['port'] = isset($redirect['port'])? $redirect['port'] : false;
if ( array($original['host'], $original['port'], $original['path'], $original['query']) !== array($redirect['host'], $redirect['port'], $redirect['path'], $redirect['query']) ) {
$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
if ( isset($redirect['port']) )
@@ -240,4 +246,4 @@ function redirect_guess_404_permalink() {
add_action('template_redirect', 'redirect_canonical');
?>
?>

View File

@@ -375,7 +375,7 @@ function delete_option( $name ) {
// Get the ID, if no ID then return
// expected_slashed ($name)
$option = $wpdb->get_row( "SELECT option_id, autoload FROM $wpdb->options WHERE option_name = '$name'" );
if ( !$option->option_id )
if ( is_null($option) || !$option->option_id )
return false;
// expected_slashed ($name)
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name = '$name'" );

View File

@@ -180,9 +180,11 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
if ( $output == OBJECT ) {
return $_post;
} elseif ( $output == ARRAY_A ) {
return get_object_vars($_post);
$__post = get_object_vars($_post);
return $__post;
} elseif ( $output == ARRAY_N ) {
return array_values(get_object_vars($_post));
$__post = array_values(get_object_vars($_post));
return $__post;
} else {
return $_post;
}
@@ -698,14 +700,17 @@ function get_post_custom_values( $key = '', $post_id = 0 ) {
function sanitize_post($post, $context = 'display') {
if ( 'raw' == $context )
return $post;
if ( is_object($post) )
if ( is_object($post) ) {
if ( !isset($post->ID) )
return $post;
foreach ( array_keys(get_object_vars($post)) as $field )
$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
else
} else {
if ( !isset($post['ID']) )
return $post;
foreach ( array_keys($post) as $field )
$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
}
return $post;
}
@@ -2366,7 +2371,7 @@ function wp_mime_type_icon( $mime = 0 ) {
* @return int Same as $post_id
*/
function wp_check_for_changed_slugs($post_id) {
if ( !strlen($_POST['wp-old-slug']) )
if ( !isset($_POST['wp-old-slug']) || !strlen($_POST['wp-old-slug']) )
return $post_id;
$post = &get_post($post_id);

View File

@@ -1154,7 +1154,7 @@ class WP_Query {
// MIME-Type stuff for attachment browsing
if ( '' != $q['post_mime_type'] )
if ( isset($q['post_mime_type']) && '' != $q['post_mime_type'] )
$whichmimetype = wp_post_mime_type_where($q['post_mime_type']);
$where .= $search.$whichcat.$whichauthor.$whichmimetype;

View File

@@ -640,6 +640,7 @@ function &get_terms($taxonomies, $args = '') {
$where .= " AND (t.name LIKE '%$search%')";
}
$select_this = '';
if ( 'all' == $fields )
$select_this = 't.*, tt.*';
else if ( 'ids' == $fields )
@@ -1041,6 +1042,7 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
$taxonomies = "'" . implode("', '", $taxonomies) . "'";
$object_ids = implode(', ', $object_ids);
$select_this = '';
if ( 'all' == $fields )
$select_this = 't.*, tt.*';
else if ( 'ids' == $fields )
@@ -1252,7 +1254,7 @@ function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
}
$t = get_taxonomy($taxonomy);
if ( ! $append && $t->sort ) {
if ( ! $append && isset($t->sort) && $t->sort ) {
$values = array();
$term_order = 0;
$final_term_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
@@ -1883,4 +1885,4 @@ function _update_post_term_count( $terms ) {
}
}
?>
?>

View File

@@ -259,7 +259,7 @@ function is_active_widget($callback) {
if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $sidebar => $widgets )
if ( is_array($widgets) ) foreach ( $widgets as $widget )
if ( $wp_registered_widgets[$widget]['callback'] == $callback )
if ( isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback )
return $sidebar;
return false;