diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-06-20 07:45:06 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-06-20 07:45:06 +0000 |
commit | 097ea891f1276389ff458b5842d44b8c5db9b41a (patch) | |
tree | bf43b095df9404cdafaa2ac2a387941359d5c5cd | |
parent | 131aff184085adea79e4597cb917d7ecc39b1f9d (diff) | |
download | brdo-097ea891f1276389ff458b5842d44b8c5db9b41a.tar.gz brdo-097ea891f1276389ff458b5842d44b8c5db9b41a.tar.bz2 |
#480414 by JamesAn: Convert comment module to drupal_static caching.
-rw-r--r-- | modules/comment/comment.module | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 60448295c..3e64620c2 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1349,7 +1349,7 @@ function comment_load($cid) { * The replies count. */ function comment_num_replies($pid) { - static $cache; + $cache = &drupal_static(__FUNCTION__, array()); if (!isset($cache[$pid])) { $cache[$pid] = db_query('SELECT COUNT(cid) FROM {comment} WHERE pid = :pid AND status = :status', array( @@ -1928,7 +1928,7 @@ function comment_form_submit($form, &$form_state) { * @ingroup themeable */ function theme_comment_view($comment, $node, $links = array(), $visible = TRUE) { - static $first_new = TRUE; + $first_new = &drupal_static(__FUNCTION__, TRUE); $comment->new = node_mark($comment->nid, $comment->timestamp); $output = ''; @@ -2096,14 +2096,11 @@ function theme_comment_thread_expanded($comment, $node) { */ function theme_comment_post_forbidden($node) { global $user; - static $authenticated_post_comments; if (!$user->uid) { - if (!isset($authenticated_post_comments)) { - // We only output any link if we are certain, that users get permission - // to post comments by logging in. We also locally cache this information. - $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval')); - } + // We only output any link if we are certain, that users get permission + // to post comments by logging in. We also locally cache this information. + $authenticated_post_comments = &drupal_static(__FUNCTION__, array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'))); if ($authenticated_post_comments) { // We cannot use drupal_get_destination() because these links |