Fixed regression that made log queries happen in spite of the bloom filter
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 20 Nov 2014 08:22:42 +0000 (00:22 -0800)
committerOri.livneh <ori@wikimedia.org>
Thu, 20 Nov 2014 09:03:29 +0000 (09:03 +0000)
Change-Id: I50f280a1db30cb1f9901a55a8a9558ebb2a9dffd

includes/logging/LogEventsList.php

index c7f5e5a..e03cf1c 100644 (file)
@@ -542,22 +542,28 @@ class LogEventsList extends ContextSource {
                        $pager->mLimit = $lim;
                }
 
-               $logBody = null;
+               $knownEmptyResult = false;
                // 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 = '';
+                                       $knownEmptyResult = true;
                                }
                        } else {
-                               $logBody = '';
+                               $knownEmptyResult = true;
                        }
                }
 
                // Fetch the log rows and build the HTML if needed
-               $logBody = ( $logBody === null ) ? $pager->getBody() : $logBody;
+               if ( $knownEmptyResult ) {
+                       $logBody = '';
+                       $numRows = 0;
+               } else {
+                       $logBody = $pager->getBody();
+                       $numRows = $pager->getNumRows();
+               }
 
                $s = '';
 
@@ -588,7 +594,7 @@ class LogEventsList extends ContextSource {
                                $context->msg( 'logempty' )->parse() );
                }
 
-               if ( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link
+               if ( $numRows > $pager->mLimit ) { # Show "Full log" link
                        $urlParam = array();
                        if ( $page instanceof Title ) {
                                $urlParam['page'] = $page->getPrefixedDBkey();
@@ -635,7 +641,7 @@ class LogEventsList extends ContextSource {
                        }
                }
 
-               return $pager->getNumRows();
+               return $numRows;
        }
 
        /**