MediaWiki REL1_31
BatchRowWriter.php
Go to the documentation of this file.
1<?php
26
31 protected $db;
32
36 protected $table;
37
41 protected $clusterName;
42
48 public function __construct( IDatabase $db, $table, $clusterName = false ) {
49 $this->db = $db;
50 $this->table = $table;
51 $this->clusterName = $clusterName;
52 }
53
60 public function write( array $updates ) {
61 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
62 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
63
64 foreach ( $updates as $update ) {
65 $this->db->update(
66 $this->table,
67 $update['changes'],
68 $update['primaryKey'],
69 __METHOD__
70 );
71 }
72
73 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
74 }
75}
__construct(IDatabase $db, $table, $clusterName=false)
write(array $updates)
MediaWikiServices is the service locator for the application scope of MediaWiki.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs table
Definition deferred.txt:16
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38