Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 29750)
+++ wp-includes/post.php	(working copy)
@@ -3672,6 +3672,13 @@
 	global $wpdb, $wp_rewrite;
 
 	$original_slug = $slug;
+	
+	// if the name is numeric, then prefix it so that the post name will work with all permalink structures
+	// https://core.trac.wordpress.org/ticket/5305
+	if ( is_numeric( $slug ) ) {
+		$slug_prefix = apply_filters( 'wp_unique_post_slug_numeric_slug_prefix', 'number-', $slug, $post_ID, $post_status, $post_type, $post_parent );
+		$slug = $slug_prefix . $slug;
+	}
 
 	$feeds = $wp_rewrite->feeds;
 	if ( ! is_array( $feeds ) )
