- private function batchDeleteByPK( $table, array $conds, array $pk, $bSize ) {
- $services = MediaWikiServices::getInstance();
- $lbFactory = $services->getDBLoadBalancerFactory();
- $dbw = $this->getDB(); // convenience
-
- $res = $dbw->select( $table, $pk, $conds, __METHOD__ );
-
- $pkDeleteConds = [];
- foreach ( $res as $row ) {
- $pkDeleteConds[] = $dbw->makeList( (array)$row, LIST_AND );
- if ( count( $pkDeleteConds ) >= $bSize ) {
- $dbw->delete( $table, $dbw->makeList( $pkDeleteConds, LIST_OR ), __METHOD__ );
- $lbFactory->commitAndWaitForReplication(
- __METHOD__, $this->ticket, [ 'domain' => $dbw->getDomainID() ]
- );
- $pkDeleteConds = [];
- }
- }
-
- if ( $pkDeleteConds ) {
- $dbw->delete( $table, $dbw->makeList( $pkDeleteConds, LIST_OR ), __METHOD__ );
- }
- }
-
- protected function getDB() {
- if ( !$this->db ) {
- $this->db = wfGetDB( DB_MASTER );
- }
-
- return $this->db;
- }
-