Opened 12 years ago
Closed 12 years ago
#27007 closed defect (bug) (fixed)
problem using wp_list_comments with 'per_page' without calling comments_template
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.9 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Comments | Keywords: | has-patch commit |
| Focuses: | Cc: |
Description (last modified by )
if you want to use wp_list_comments like this
wp_list_comments(
['style' => 'div',
'reply_text' => 'kommentieren',
'avatar_size' => 73,
'per_page' => 10000000 //or 0 or something
])
)
without using the comments_template method, there will be corrupted comment metadata links like this
.../comment-page-#comment-15922
...in my opinion( and this core hack fixed it temporarily) it has to do with the methods Walker_Comment::comment and Walker_Comment::html5_comment which doesnt pass the $args to the get_comment_link method.
So i think they should pass the args or if there are good reasons for this behavior the documentation have to be changed(http://codex.wordpress.org/Function_Reference/wp_list_comments).
Attachments (1)
Change History (8)
#3
in reply to:
↑ 1
@
12 years ago
Replying to bcworkz:
The paged_walk() method is not overridden, so the call goes to
Walker::paged_walk()which only accepts 4 parameters,$rwas the 5th!
That's not actually an issue, additional arguments are retrieved using func_get_args():
tags/3.8.1/src/wp-includes/class-wp-walker.php#L276
#4
@
12 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 3.9
per_page is actually not required, I was able to reproduce the issue with this example:
wp_list_comments( array(), get_comments() );
Looks like get_comment_link() can only generate an invalid link if $in_comment_loop is true and cpage query var is empty: tags/3.8.1/src/wp-includes/comment-template.php#L586.
$in_comment_loop is set by wp_list_comments(), and cpage is normally set by comments_template(): tags/3.8.1/src/wp-includes/comment-template.php#L1078.
So, if wp_list_comments() is called outside of comments.php template, invalid links are generated. Passing $args to get_comment_link() in Walker_Comment::html5_comment() and Walker_Comment::comment() does indeed fix the issue.
The original arguments are not available to pass to
get_comment_link().It appears nearly all the methods involved prior to that call are capable of passing the arguments through.
wp_list_comments()actually tries to pass the arguments as$rin the call to$walker->paged_walk(). The paged_walk() method is not overridden, so the call goes toWalker::paged_walk()which only accepts 4 parameters,$rwas the 5th!This of course does not alone solve the corrupted link issue, but by ensuring the arguments can actually get passed through the walker object as was apparently intended would at least make it possible.