/** * Are article comments enabled for context title? */ private function checkArticleComments() { $this->isArticleComments = class_exists('ArticleComment') && ArticleCommentInit::ArticleCommentCheckTitle($this->contextTitle); return $this->isArticleComments; }
/** * Get number of article comments for current page (if enabled) or get number of revisions of talk page */ public function getCommentsCount() { wfProfileIn(__METHOD__); global $wgMemc; if (!is_null($this->mTitle)) { $title = $this->mTitle; } else { $title = Title::newFromId($this->pageId); } // don't perform for talk pages or special pages if (empty($title) || $title->isTalkPage() || $title->isSpecialPage()) { wfProfileOut(__METHOD__); return 0; } // try to get cached data $key = $this->getKey('comments6'); $ret = $wgMemc->get($key); if (!is_numeric($ret)) { wfProfileIn(__METHOD__ . '::miss'); // new comments extension if (self::isArticleCommentsEnabled() && ArticleCommentInit::ArticleCommentCheckTitle($title)) { // get number of article comments $commentList = ArticleCommentList::newFromTitle($title); $data = $commentList->getData(); $ret = $data['countCommentsNested']; wfDebug(__METHOD__ . "::miss - using comments count\n"); } else { // get number of revisions of talk page $talkPage = $title->getTalkPage(); // check if talk page exists if (!empty($talkPage) && $talkPage->exists()) { $dbr = wfGetDB(DB_SLAVE); $ret = $dbr->selectField('revision', 'count(*)', array('rev_page' => $talkPage->getArticleId()), __METHOD__); } else { $ret = 0; } wfDebug(__METHOD__ . "::miss - using talk page revisions count\n"); } $wgMemc->set($key, $ret, self::CACHE_TTL); wfProfileOut(__METHOD__ . '::miss'); } wfProfileOut(__METHOD__); return intval($ret); }