WordPress.org

Make WordPress Core

Ticket #10758: 10758-wp-includes-post.patch

File 10758-wp-includes-post.patch, 2.1 KB (added by hakre, 5 years ago)

Not a fix of #4365

  • wp-includes/post.php

     
    17981798/** 
    17991799 * Given the desired slug and some post details computes a unique slug for the post. 
    18001800 * 
     1801 * @global wpdb $wpdb 
     1802 * @global WP_Rewrite $wp_rewrite 
    18011803 * @param string $slug the desired slug (post_name) 
    18021804 * @param integer $post_ID 
    18031805 * @param string $post_status no uniqueness checks are made if the post is still draft or pending 
     
    18081810function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) { 
    18091811        if ( in_array( $post_status, array( 'draft', 'pending' ) ) ) 
    18101812                return $slug; 
    1811          
     1813        /* 
     1814         * @var $wp_rewrite WP_Rewrite  
     1815         * @var $wpdb wpdb  
     1816         */ 
    18121817        global $wpdb, $wp_rewrite; 
    18131818        $hierarchical_post_types = apply_filters('hierarchical_post_types', array('page')); 
    18141819        if ( 'attachment' == $post_type ) { 
     
    18311836                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode("', '", $wpdb->escape($hierarchical_post_types)) . "' ) AND ID != %d AND post_parent = %d LIMIT 1"; 
    18321837                $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID, $post_parent)); 
    18331838                 
    1834                 if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) { 
     1839                $feeds = $wp_rewrite->feeds; 
     1840                if ( is_null($feeds) ) 
     1841                        $feeds = array(); 
     1842         
     1843                if ( $post_name_check || in_array($slug, $feeds) ) { 
    18351844                        $suffix = 2; 
    18361845                        do { 
    18371846                                $alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix"; 
     
    18451854                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; 
    18461855                $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID)); 
    18471856                 
    1848                 if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) { 
     1857                $feeds = $wp_rewrite->feeds; 
     1858                if ( is_null($feeds) ) 
     1859                        $feeds = array(); 
     1860 
     1861                if ( $post_name_check || in_array($slug, $feeds) ) { 
    18491862                        $suffix = 2; 
    18501863                        do { 
    18511864                                $alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix";