From: umherirrender Date: Sun, 2 Mar 2014 18:07:06 +0000 (+0100) Subject: Use a secondary db connection for Revsion::getParentLength in api X-Git-Tag: 1.31.0-rc.0~16758 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=44c60036b5cfd588f6f8e80917b3d336e720aeed;p=lhc%2Fweb%2Fwiklou.git Use a secondary db connection for Revsion::getParentLength in api Getting api connection before the connection is set to the named connection and store it in a local var to use it later. Same comment as in Special:Contributions Bug: 61982 Change-Id: Ia66c4a65a24876e2a528034e8e003aa535e6b689 --- diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index 9ad77d4860..16108a2c90 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -56,6 +56,11 @@ class ApiQueryContributions extends ApiQueryBase { $this->fld_patrolled = isset( $prop['patrolled'] ); $this->fld_tags = isset( $prop['tags'] ); + // Most of this code will use the 'contributions' group DB, which can map to slaves + // with extra user based indexes or partioning by user. The additional metadata + // queries should use a regular slave since the lookup pattern is not all by user. + $dbSecondary = $this->getDB(); // any random slave + // TODO: if the query is going only against the revision table, should this be done? $this->selectNamedDB( 'contributions', DB_SLAVE, 'contributions' ); @@ -90,7 +95,7 @@ class ApiQueryContributions extends ApiQueryBase { $revIds[] = $row->rev_parent_id; } } - $this->parentLens = Revision::getParentLengths( $this->getDB(), $revIds ); + $this->parentLens = Revision::getParentLengths( $dbSecondary, $revIds ); $res->rewind(); // reset }