X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=ecbbb85117f41401b8ac34c68fc7c9273133ac58;hb=ed520fddd94c49331d88858ca834b5dacfff35b4;hp=62dc36c18d43bf1c5f67c1e0a914508d9ab3be58;hpb=22806b0a4509e97b56fb52b387e17e3c80fb7eb2;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 62dc36c18d..ecbbb85117 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -25,6 +25,8 @@ require_once __DIR__ . '/../includes/PHPVersionCheck.php'; wfEntryPointCheck( 'cli' ); +use Wikimedia\Rdbms\DBReplicationWaitError; + /** * @defgroup MaintenanceArchive Maintenance archives * @ingroup Maintenance @@ -36,9 +38,11 @@ define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless $maintClass = false; +use Wikimedia\Rdbms\IDatabase; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\LBFactory; +use Wikimedia\Rdbms\IMaintainableDatabase; /** * Abstract maintenance class for quickly writing and churning out @@ -105,7 +109,7 @@ abstract class Maintenance { /** * Used by getDB() / setDB() - * @var Database + * @var IMaintainableDatabase */ private $mDb = null; @@ -205,7 +209,7 @@ abstract class Maintenance { * @param string $description The description of the param to show on --help * @param bool $required Is the param required? * @param bool $withArg Is an argument required with this option? - * @param string $shortName Character to use as short name + * @param string|bool $shortName Character to use as short name * @param bool $multiOccurrence Can this option be passed multiple times? */ protected function addOption( $name, $description, $required = false, @@ -340,7 +344,7 @@ abstract class Maintenance { * @return mixed */ protected function getStdin( $len = null ) { - if ( $len == Maintenance::STDIN_ALL ) { + if ( $len == self::STDIN_ALL ) { return file_get_contents( 'php://stdin' ); } $f = fopen( 'php://stdin', 'rt' ); @@ -453,7 +457,7 @@ abstract class Maintenance { * @return int */ public function getDbType() { - return Maintenance::DB_STD; + return self::DB_STD; } /** @@ -1239,10 +1243,10 @@ abstract class Maintenance { * If not set, wfGetDB() will be used. * This function has the same parameters as wfGetDB() * - * @param integer $db DB index (DB_REPLICA/DB_MASTER) - * @param array $groups; default: empty array - * @param string|bool $wiki; default: current wiki - * @return Database + * @param int $db DB index (DB_REPLICA/DB_MASTER) + * @param array $groups default: empty array + * @param string|bool $wiki default: current wiki + * @return IMaintainableDatabase */ protected function getDB( $db, $groups = [], $wiki = false ) { if ( is_null( $this->mDb ) ) { @@ -1255,7 +1259,7 @@ abstract class Maintenance { /** * Sets database object to be returned by getDB(). * - * @param IDatabase $db Database object to be used + * @param IDatabase $db */ public function setDB( IDatabase $db ) { $this->mDb = $db; @@ -1317,7 +1321,7 @@ abstract class Maintenance { /** * Lock the search index - * @param Database &$db + * @param IMaintainableDatabase &$db */ private function lockSearchindex( $db ) { $write = [ 'searchindex' ]; @@ -1335,7 +1339,7 @@ abstract class Maintenance { /** * Unlock the tables - * @param Database &$db + * @param IMaintainableDatabase &$db */ private function unlockSearchindex( $db ) { $db->unlockTables( __CLASS__ . '::' . __METHOD__ ); @@ -1344,7 +1348,7 @@ abstract class Maintenance { /** * Unlock and lock again * Since the lock is low-priority, queued reads will be able to complete - * @param Database &$db + * @param IMaintainableDatabase &$db */ private function relockSearchindex( $db ) { $this->unlockSearchindex( $db ); @@ -1355,7 +1359,7 @@ abstract class Maintenance { * Perform a search index update with locking * @param int $maxLockTime The maximum time to keep the search index locked. * @param string $callback The function that will update the function. - * @param Database $dbw + * @param IMaintainableDatabase $dbw * @param array $results */ public function updateSearchIndex( $maxLockTime, $callback, $dbw, $results ) { @@ -1391,7 +1395,7 @@ abstract class Maintenance { /** * Update the searchindex table for a given pageid - * @param Database $dbw A database write handle + * @param IDatabase $dbw A database write handle * @param int $pageId The page ID to update. * @return null|string */