diff --git a/wp-includes/meta.php b/wp-includes/meta.php
index 2332d9b5af..18d1f7fe73 100644
--- a/wp-includes/meta.php
+++ b/wp-includes/meta.php
@@ -207,7 +207,7 @@ function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_
 	// Compare existing value to new value if no prev value given and the key exists only once.
 	if ( empty( $prev_value ) ) {
 		$old_value = get_metadata( $meta_type, $object_id, $meta_key );
-		if ( count( $old_value ) == 1 ) {
+		if ( is_countable( $old_value ) && 1 === count( $old_value ) ) {
 			if ( $old_value[0] === $meta_value ) {
 				return false;
 			}
