MediaWiki  1.34.0
SessionConsistentConnectionManager.php
Go to the documentation of this file.
1 <?php
22 namespace Wikimedia\Rdbms;
23 
46 
50  private $forceWriteConnection = false;
51 
58  public function prepareForUpdates() {
59  $this->forceWriteConnection = true;
60  }
61 
69  public function getReadConnection( array $groups = null ) {
70  if ( $this->forceWriteConnection ) {
71  return parent::getWriteConnection();
72  }
73 
74  return parent::getReadConnection( $groups );
75  }
76 
82  public function getWriteConnection() {
83  $this->prepareForUpdates();
84  return parent::getWriteConnection();
85  }
86 
94  public function getReadConnectionRef( array $groups = null ) {
95  if ( $this->forceWriteConnection ) {
96  return parent::getWriteConnectionRef();
97  }
98 
99  return parent::getReadConnectionRef( $groups );
100  }
101 
107  public function getWriteConnectionRef() {
108  $this->prepareForUpdates();
109  return parent::getWriteConnectionRef();
110  }
111 
112 }
Wikimedia\Rdbms\SessionConsistentConnectionManager\prepareForUpdates
prepareForUpdates()
Forces all future calls to getReadConnection() to return a write connection.
Definition: SessionConsistentConnectionManager.php:58
Wikimedia\Rdbms\SessionConsistentConnectionManager\getWriteConnectionRef
getWriteConnectionRef()
Definition: SessionConsistentConnectionManager.php:107
Wikimedia\Rdbms\SessionConsistentConnectionManager\getReadConnectionRef
getReadConnectionRef(array $groups=null)
Definition: SessionConsistentConnectionManager.php:94
Wikimedia\Rdbms
Definition: ChronologyProtector.php:24
Wikimedia\Rdbms\ConnectionManager\$groups
string[] $groups
Definition: ConnectionManager.php:52
Wikimedia\Rdbms\SessionConsistentConnectionManager\getReadConnection
getReadConnection(array $groups=null)
Definition: SessionConsistentConnectionManager.php:69
Wikimedia\Rdbms\SessionConsistentConnectionManager\getWriteConnection
getWriteConnection()
Definition: SessionConsistentConnectionManager.php:82
Wikimedia\Rdbms\ConnectionManager
Database connection manager.
Definition: ConnectionManager.php:35
Wikimedia\Rdbms\SessionConsistentConnectionManager\$forceWriteConnection
bool $forceWriteConnection
Definition: SessionConsistentConnectionManager.php:50
Wikimedia\Rdbms\SessionConsistentConnectionManager
Database connection manager.
Definition: SessionConsistentConnectionManager.php:45