MediaWiki REL1_37
SessionConsistentConnectionManager.php
Go to the documentation of this file.
1<?php
22namespace Wikimedia\Rdbms;
23
46
50 private $forceWriteConnection = false;
51
58 public function prepareForUpdates() {
59 $this->forceWriteConnection = true;
60 }
61
71 public function getReadConnection( ?array $groups = null, int $flags = 0 ) {
72 if ( $this->forceWriteConnection ) {
73 return parent::getWriteConnection( $flags );
74 }
75
76 return parent::getReadConnection( $groups, $flags );
77 }
78
87 public function getWriteConnection( int $flags = 0 ) {
88 $this->prepareForUpdates();
89 return parent::getWriteConnection( $flags );
90 }
91
99 public function getReadConnectionRef( array $groups = null ) {
100 if ( $this->forceWriteConnection ) {
101 return parent::getWriteConnectionRef();
102 }
103
104 return parent::getReadConnectionRef( $groups );
105 }
106
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.