summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-22 15:38:52 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-22 15:38:52 +0000
commit32c34106dc98e288687cff933373e164cfc47563 (patch)
tree832749f155dd3485ccfa6834924e0a3d485a78be
parent424cc9bbb1f790b0f325067a6b3b29fd765c609e (diff)
downloadbrdo-32c34106dc98e288687cff933373e164cfc47563.tar.gz
brdo-32c34106dc98e288687cff933373e164cfc47563.tar.bz2
#606608 follow-up by Gábor Hojtsy and sun: Go back to numeric placeholders for comment menu paths for performance.
-rw-r--r--modules/comment/comment.admin.inc10
-rw-r--r--modules/comment/comment.module40
-rw-r--r--modules/comment/comment.pages.inc17
3 files changed, 43 insertions, 24 deletions
diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc
index 26f62696d..d68e4e0fb 100644
--- a/modules/comment/comment.admin.inc
+++ b/modules/comment/comment.admin.inc
@@ -234,6 +234,16 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) {
}
/**
+ * Page callback for comment deletions.
+ */
+function comment_confirm_delete_page($cid) {
+ if ($comment = comment_load($cid)) {
+ return drupal_get_form('comment_confirm_delete', $comment);
+ }
+ return MENU_NOT_FOUND;
+}
+
+/**
* Form builder; Builds the confirmation form for deleting a single comment.
*
* @ingroup forms
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 68be18b92..0035b0a99 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -233,45 +233,44 @@ function comment_menu() {
'access arguments' => array('administer comments'),
'type' => MENU_LOCAL_TASK,
);
- $items['comment/%comment'] = array(
+ $items['comment/%'] = array(
'title' => 'Comment permalink',
'page callback' => 'comment_permalink',
'page arguments' => array(1),
'access arguments' => array('access comments'),
'type' => MENU_CALLBACK,
);
- $items['comment/%comment/view'] = array(
+ $items['comment/%/view'] = array(
'title' => 'View comment',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
+ // Every other comment path uses %, but this one loads the comment directly,
+ // so we don't end up loading it twice (in the page and access callback).
$items['comment/%comment/edit'] = array(
'title' => 'Edit',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('comment_form', 1),
+ 'page callback' => 'comment_edit_page',
+ 'page arguments' => array(1),
'access callback' => 'comment_access',
'access arguments' => array('edit', 1),
'type' => MENU_LOCAL_TASK,
- 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'weight' => 0,
);
- $items['comment/%comment/approve'] = array(
+ $items['comment/%/approve'] = array(
'title' => 'Approve',
'page callback' => 'comment_approve',
'page arguments' => array(1),
'access arguments' => array('administer comments'),
- 'type' => MENU_LOCAL_TASK,
- 'context' => MENU_CONTEXT_INLINE,
+ 'type' => MENU_CALLBACK,
'file' => 'comment.pages.inc',
'weight' => 1,
);
- $items['comment/%comment/delete'] = array(
+ $items['comment/%/delete'] = array(
'title' => 'Delete',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('comment_confirm_delete', 1),
+ 'page callback' => 'comment_confirm_delete_page',
+ 'page arguments' => array(1),
'access arguments' => array('administer comments'),
'type' => MENU_LOCAL_TASK,
- 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'file' => 'comment.admin.inc',
'weight' => 2,
);
@@ -437,14 +436,13 @@ function comment_block_view($delta = '') {
* calculates the page number based on current comment settings and returns
* the full comment view with the pager set dynamically.
*
- * @param $comment
- * A comment object.
+ * @param $cid
+ * A comment identifier.
* @return
* The comment listing set to the page on which the comment appears.
*/
-function comment_permalink($comment) {
- $node = node_load($comment->nid);
- if ($node && $comment) {
+function comment_permalink($cid) {
+ if (($comment = comment_load($cid)) && ($node = node_load($comment->nid))) {
// Find the current display page for this comment.
$page = comment_get_display_page($comment->cid, $node->type);
@@ -1718,6 +1716,14 @@ function comment_get_display_page($cid, $node_type) {
}
/**
+ * Page callback for comment editing.
+ */
+function comment_edit_page($comment) {
+ drupal_set_title(t('Edit comment %comment', array('%comment' => $comment->subject)), PASS_THROUGH);
+ return drupal_get_form('comment_form', $comment);
+}
+
+/**
* Generate the basic commenting form, for appending to a node or display on a separate page.
*
* @ingroup forms
diff --git a/modules/comment/comment.pages.inc b/modules/comment/comment.pages.inc
index 2ad1c77a4..4156beb18 100644
--- a/modules/comment/comment.pages.inc
+++ b/modules/comment/comment.pages.inc
@@ -103,13 +103,16 @@ function comment_reply($node, $pid = NULL) {
/**
* Menu callback; publish specified comment.
*
- * @param $comment
- * A comment object.
+ * @param $cid
+ * A comment identifier.
*/
-function comment_approve($comment) {
- $comment->status = COMMENT_PUBLISHED;
- comment_save($comment);
+function comment_approve($cid) {
+ if ($comment = comment_load($cid)) {
+ $comment->status = COMMENT_PUBLISHED;
+ comment_save($comment);
- drupal_set_message(t('Comment approved.'));
- drupal_goto('node/' . $comment->nid);
+ drupal_set_message(t('Comment approved.'));
+ drupal_goto('node/' . $comment->nid);
+ }
+ return MENU_NOT_FOUND;
}