$alias = drupal_get_path_alias('node/' . $comment->nid);
$node = node_load($comment->nid);
$page = comment_get_display_page($comment->cid, $node->type);
if ($page > 0) {
if ($alias != $current_path) {
return array(
'path' => drupal_get_path_alias('node/' . $comment->nid),
'options' => array('fragment' => 'comment-' . $comment->cid, 'query' => array('page' => $page)),
);
}
drupal_get_path_alias() is called further up. Surely it doesn't need to be called again (several times) further on, as the parameters are the same.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2227073.diff | 2.72 KB | drumm |
Comments
Comment #1
danpros commentedHi joachim,
Thanks for pointing it out :) yup it will save many unneeded DB query.
Comment #2
drummActually, we don't even need to call it at all. The path goes through
url()on the way to rendering, which does path lookups. The attached patch simplifies the code quite a bit knowing this, and clean up some whitespace.This can trigger #1200478: Changing the comment path to the node path triggers a PHP fatal error in l() due to wrongly structured options.
Comment #3
sunLooks great to me. And indeed, manually retrieving the alias is unnecessary, since
l()already performs aliasing.Comment #4
danpros commentedI already add @drumm as the maintainer.
Currently I have 52138 comments from 5635 nodes on the site (the demo link) so I can use it to test it.
Note: let me know if anyone need maintainer role on this project.
Comment #6
drummCommitted. (We shouldn't make a point release until #1200478: Changing the comment path to the node path triggers a PHP fatal error in l() due to wrongly structured options is release in core.)