While prepping the code base for using etsy/phan i found a few problems.
A couple are real problems, while others are just places etsy couldn't
figure out the types.
* AuthPlugin referenced UserLoginTemplate which doesn't exist. Tracing
back usages this accepts classes that extend from BaseTemplate.
* DatabaseSqlite had an invalid @var annotation.
* LoadBalancer had some missing or under-defined annotations. Make them
more specific where possible.
* SqlBagOStuff didn't have the appropriate use statement for
WaitConditionLoop and probably doesn't work. Also updated annotations
that point to non-existent DatabaseBase to use IDatabase.
Change-Id: Iff2270b418ad2f8f97cfdb6df646c435d3283536
/**
* Modify options in the login template.
*
/**
* Modify options in the login template.
*
- * @param UserLoginTemplate $template
+ * @param BaseTemplate $template
* @param string $type 'signup' or 'login'. Added in 1.16.
*/
public function modifyUITemplate( &$template, &$type ) {
* @param string $type 'signup' or 'login'. Added in 1.16.
*/
public function modifyUITemplate( &$template, &$type ) {
/** @var resource */
protected $mLastResult;
/** @var resource */
protected $mLastResult;
protected $mConn;
/** @var FSLockManager (hopefully on the same server as the DB) */
protected $mConn;
/** @var FSLockManager (hopefully on the same server as the DB) */
class LoadBalancer implements ILoadBalancer {
/** @var array[] Map of (server index => server config array) */
private $mServers;
class LoadBalancer implements ILoadBalancer {
/** @var array[] Map of (server index => server config array) */
private $mServers;
- /** @var array[] Map of (local/foreignUsed/foreignFree => server index => IDatabase array) */
+ /** @var IDatabase[][] Map of (local/foreignUsed/foreignFree => server index => IDatabase array) */
private $mConns;
/** @var float[] Map of (server index => weight) */
private $mLoads;
private $mConns;
/** @var float[] Map of (server index => weight) */
private $mLoads;
+ /**
+ * @param DBMasterPos|false $pos
+ */
public function waitFor( $pos ) {
$this->mWaitForPos = $pos;
$i = $this->mReadIndex;
public function waitFor( $pos ) {
$this->mWaitForPos = $pos;
$i = $this->mReadIndex;
+ /**
+ * @param int $i
+ * @return IDatabase
+ */
public function getAnyOpenConnection( $i ) {
foreach ( $this->mConns as $connsByServer ) {
if ( !empty( $connsByServer[$i] ) ) {
public function getAnyOpenConnection( $i ) {
foreach ( $this->mConns as $connsByServer ) {
if ( !empty( $connsByServer[$i] ) ) {
+ /**
+ * @param IDatabase $conn
+ * @param DBMasterPos|false $pos
+ * @param int $timeout
+ */
public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 ) {
if ( $this->getServerCount() <= 1 || !$conn->getLBInfo( 'replica' ) ) {
return true; // server is not a replica DB
public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 ) {
if ( $this->getServerCount() <= 1 || !$conn->getLBInfo( 'replica' ) ) {
return true; // server is not a replica DB
*/
use \MediaWiki\MediaWikiServices;
*/
use \MediaWiki\MediaWikiServices;
+use \Wikimedia\WaitConditionLoop;
/**
* Class to store objects in the database
/**
* Class to store objects in the database
/**
* The dependency-injected database to use.
*
/**
* The dependency-injected database to use.
*
- * @var DatabaseBase|null
* @todo Fixme: the --server parameter is currently not respected, as it
* doesn't seem terribly easy to ask the load balancer for a particular
* connection by name.
* @todo Fixme: the --server parameter is currently not respected, as it
* doesn't seem terribly easy to ask the load balancer for a particular
* connection by name.
*/
function backupDb() {
if ( $this->forcedDb !== null ) {
*/
function backupDb() {
if ( $this->forcedDb !== null ) {
* Force the dump to use the provided database connection for database
* operations, wherever possible.
*
* Force the dump to use the provided database connection for database
* operations, wherever possible.
*
- * @param DatabaseBase|null $db (Optional) the database connection to use. If null, resort to
+ * @param IDatabase|null $db (Optional) the database connection to use. If null, resort to
* use the globally provided ways to get database connections.
*/
function setDB( IDatabase $db = null ) {
* use the globally provided ways to get database connections.
*/
function setDB( IDatabase $db = null ) {