Made LogEventsList use the log bloom filter, not just the Article class
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 31 Oct 2014 21:16:06 +0000 (14:16 -0700)
committerOri.livneh <ori@wikimedia.org>
Mon, 3 Nov 2014 21:44:15 +0000 (21:44 +0000)
Change-Id: I6c523d4ecd60dab080537cabc5aa1c632950e018

includes/logging/LogEventsList.php
includes/page/Article.php

index 70f1f1a..8421672 100644 (file)
@@ -535,7 +535,23 @@ class LogEventsList extends ContextSource {
                        $pager->mLimit = $lim;
                }
 
-               $logBody = $pager->getBody();
+               $logBody = null;
+               // Check if we can avoid the DB query all together
+               if ( $page !== '' && !$param['useMaster'] ) {
+                       $title = ( $page instanceof Title ) ? $page : Title::newFromText( $page );
+                       if ( $title ) {
+                               $member = $title->getNamespace() . ':' . $title->getDBkey();
+                               if ( !BloomCache::get( 'main' )->check( wfWikiId(), 'TitleHasLogs', $member ) ) {
+                                       $logBody = '';
+                               }
+                       } else {
+                               $logBody = '';
+                       }
+               }
+
+               // Fetch the log rows and build the HTML if needed
+               $logBody = ( $logBody === null ) ? $pager->getBody() : $logBody;
+
                $s = '';
 
                if ( $logBody ) {
index 54fab29..7900b2c 100644 (file)
@@ -1248,16 +1248,12 @@ class Article implements Page {
                wfRunHooks( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) );
 
                # Show delete and move logs
-               $member = $title->getNamespace() . ':' . $title->getDBkey();
-               // @todo: move optimization to showLogExtract()?
-               if ( BloomCache::get( 'main' )->check( wfWikiId(), 'TitleHasLogs', $member ) ) {
-                       LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '',
-                               array( 'lim' => 10,
-                                       'conds' => $conds,
-                                       'showIfEmpty' => false,
-                                       'msgKey' => array( 'moveddeleted-notice' ) )
-                       );
-               }
+               LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '',
+                       array( 'lim' => 10,
+                               'conds' => $conds,
+                               'showIfEmpty' => false,
+                               'msgKey' => array( 'moveddeleted-notice' ) )
+               );
 
                if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
                        // If there's no backing content, send a 404 Not Found