Make WordPress Core

Ticket #35356: comment-template.patch

File comment-template.patch, 4.0 KB (added by ivankristianto, 9 years ago)

This patch should fix this issue.

  • wp-includes/comment-template.php

     
    19051905         */
    19061906        $r = apply_filters( 'wp_list_comments_args', $r );
    19071907
    1908         /*
    1909          * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
    1910          * perform a separate comment query and allow Walker_Comment to paginate.
    1911          */
    1912         if ( is_singular() && ( $r['page'] || $r['per_page'] ) ) {
    1913                 $current_cpage = get_query_var( 'cpage' );
    1914                 if ( ! $current_cpage ) {
    1915                         $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
    1916                 }
    1917 
    1918                 $current_per_page = get_query_var( 'comments_per_page' );
    1919                 if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
    1920                         $comments = get_comments( array(
    1921                                 'post_id' => get_queried_object_id(),
    1922                                 'orderby' => 'comment_date_gmt',
    1923                                 'order' => 'ASC',
    1924                                 'status' => 'all',
    1925                         ) );
    1926                 }
    1927         }
    1928 
    19291908        // Figure out what comments we'll be looping through ($_comments)
    19301909        if ( null !== $comments ) {
    19311910                $comments = (array) $comments;
     
    19401919                        $_comments = $comments;
    19411920                }
    19421921        } else {
    1943                 if ( empty($wp_query->comments) )
    1944                         return;
    1945                 if ( 'all' != $r['type'] ) {
    1946                         if ( empty($wp_query->comments_by_type) )
    1947                                 $wp_query->comments_by_type = separate_comments($wp_query->comments);
    1948                         if ( empty($wp_query->comments_by_type[$r['type']]) )
    1949                                 return;
    1950                         $_comments = $wp_query->comments_by_type[$r['type']];
    1951                 } else {
    1952                         $_comments = $wp_query->comments;
    1953                 }
     1922                /*
     1923                 * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
     1924                 * perform a separate comment query and allow Walker_Comment to paginate.
     1925                 */
     1926                if ( is_singular() && ( $r['page'] || $r['per_page'] ) ) {
     1927                        $current_cpage = get_query_var( 'cpage' );
     1928                        if ( ! $current_cpage ) {
     1929                                $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
     1930                        }
    19541931
    1955                 // Pagination is already handled by `WP_Comment_Query`, so we tell Walker not to bother.
    1956                 if ( $wp_query->max_num_comment_pages ) {
    1957                         $default_comments_page = get_option( 'default_comments_page' );
    1958                         $cpage = get_query_var( 'cpage' );
    1959                         if ( 'newest' === $default_comments_page ) {
    1960                                 $r['cpage'] = $cpage;
     1932                        $current_per_page = get_query_var( 'comments_per_page' );
     1933                        if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
     1934                                $comments = get_comments( array(
     1935                                        'post_id' => get_queried_object_id(),
     1936                                        'orderby' => 'comment_date_gmt',
     1937                                        'order' => 'ASC',
     1938                                        'status' => 'all',
     1939                                ) );
    19611940
    1962                         // When first page shows oldest comments, post permalink is the same as the comment permalink.
    1963                         } elseif ( $cpage == 1 ) {
    1964                                 $r['cpage'] = '';
     1941                                if ( 'all' != $r['type'] ) {
     1942                                        $comments_by_type = separate_comments($comments);
     1943                                        if ( empty($comments_by_type[$r['type']]) )
     1944                                                return;
     1945                                        $_comments = $comments_by_type[$r['type']];
     1946                                } else {
     1947                                        $_comments = $comments;
     1948                                }
     1949                        }
     1950                } else {
     1951                        if ( empty($wp_query->comments) )
     1952                                return;
     1953                        if ( 'all' != $r['type'] ) {
     1954                                if ( empty($wp_query->comments_by_type) )
     1955                                        $wp_query->comments_by_type = separate_comments($wp_query->comments);
     1956                                if ( empty($wp_query->comments_by_type[$r['type']]) )
     1957                                        return;
     1958                                $_comments = $wp_query->comments_by_type[$r['type']];
    19651959                        } else {
    1966                                 $r['cpage'] = $cpage;
     1960                                $_comments = $wp_query->comments;
    19671961                        }
    19681962
    1969                         $r['page'] = 0;
    1970                         $r['per_page'] = 0;
     1963                        if ( $wp_query->max_num_comment_pages ) {
     1964                                $default_comments_page = get_option( 'default_comments_page' );
     1965                                $cpage = get_query_var( 'cpage' );
     1966                                if ( 'newest' === $default_comments_page ) {
     1967                                        $r['cpage'] = $cpage;
     1968
     1969                                // When first page shows oldest comments, post permalink is the same as the comment permalink.
     1970                                } elseif ( $cpage == 1 ) {
     1971                                        $r['cpage'] = '';
     1972                                } else {
     1973                                        $r['cpage'] = $cpage;
     1974                                }
     1975
     1976                                $r['page'] = 0;
     1977                                $r['per_page'] = 0;
     1978                        }
    19711979                }
    19721980        }
    19731981