MediaWiki 1.40.4
SessionConsistentConnectionManager.php
Go to the documentation of this file.
1<?php
20namespace Wikimedia\Rdbms;
21
44
48 private $forceWriteConnection = false;
49
56 public function prepareForUpdates() {
57 $this->forceWriteConnection = true;
58 }
59
69 public function getReadConnection( ?array $groups = null, int $flags = 0 ) {
70 if ( $this->forceWriteConnection ) {
71 return parent::getWriteConnection( $flags );
72 }
73
74 return parent::getReadConnection( $groups, $flags );
75 }
76
85 public function getWriteConnection( int $flags = 0 ) {
86 $this->prepareForUpdates();
87 return parent::getWriteConnection( $flags );
88 }
89
98 public function getReadConnectionRef( array $groups = null ) {
99 if ( $this->forceWriteConnection ) {
100 return parent::getWriteConnectionRef();
101 }
102
103 return parent::getReadConnectionRef( $groups );
104 }
105
112 public function getWriteConnectionRef() {
113 $this->prepareForUpdates();
114 return parent::getWriteConnectionRef();
115 }
116
117}
Database connection manager.
prepareForUpdates()
Forces all future calls to getReadConnection() to return a write connection.