From b8c2db06930f0238dee80d2fa1e45da0342f64e7 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 12 May 2016 23:27:24 -0700 Subject: [PATCH] LinkHolderArray: Use LinkBatch for generating WHERE in query The entire query could be replaced with LinkBatch, but that will require further refactoring. Change-Id: I87cf2a391486e36e73a13baac65d243fc9196b5c --- includes/parser/LinkHolderArray.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index 04b5614be6..1ff49ee18e 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -297,7 +297,9 @@ class LinkHolderArray { $linkcolour_ids = []; # Generate query - $queries = []; + $lb = new LinkBatch(); + $lb->setCaller( __METHOD__ ); + foreach ( $this->internals as $ns => $entries ) { foreach ( $entries as $entry ) { /** @var Title $title */ @@ -325,23 +327,12 @@ class LinkHolderArray { $colours[$pdbk] = 'new'; } else { # Not in the link cache, add it to the query - $queries[$ns][] = $title->getDBkey(); + $lb->addObj( $title ); } } } } - if ( $queries ) { - $where = []; - foreach ( $queries as $ns => $pages ) { - $where[] = $dbr->makeList( - [ - 'page_namespace' => $ns, - 'page_title' => array_unique( $pages ), - ], - LIST_AND - ); - } - + if ( !$lb->isEmpty() ) { $fields = [ 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ]; @@ -355,7 +346,7 @@ class LinkHolderArray { $res = $dbr->select( 'page', $fields, - $dbr->makeList( $where, LIST_OR ), + $lb->constructSet( 'page', $dbr ), __METHOD__ ); -- 2.20.1