MediaWiki REL1_39
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
97 public function getReadConnectionRef( array $groups = null ) {
98 if ( $this->forceWriteConnection ) {
99 return parent::getWriteConnectionRef();
100 }
101
102 return parent::getReadConnectionRef( $groups );
103 }
104
110 public function getWriteConnectionRef() {
111 $this->prepareForUpdates();
112 return parent::getWriteConnectionRef();
113 }
114
115}
Database connection manager.
prepareForUpdates()
Forces all future calls to getReadConnection() to return a write connection.