diff --git a/src/wp-includes/rewrite.php b/src/wp-includes/rewrite.php
index 4a204c2601..b35dcabf42 100644
--- a/src/wp-includes/rewrite.php
+++ b/src/wp-includes/rewrite.php
@@ -410,7 +410,10 @@ function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) {
 	}
 
 	// This is the potentially clashing slug.
-	$value = $query_vars[ $compare ];
+	$value = '';
+	if ( $compare && array_key_exists( $compare, $query_vars ) ) {
+		$value = $query_vars[ $compare ];
+	}
 
 	$post = get_page_by_path( $value, OBJECT, 'post' );
 	if ( ! ( $post instanceof WP_Post ) ) {
