require_once __DIR__ . '/../includes/PHPVersionCheck.php';
wfEntryPointCheck( 'cli' );
+use Wikimedia\Rdbms\DBReplicationWaitError;
+
/**
* @defgroup MaintenanceArchive Maintenance archives
* @ingroup Maintenance
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\LBFactory;
+use Wikimedia\Rdbms\IMaintainableDatabase;
/**
* Abstract maintenance class for quickly writing and churning out
/**
* Used by getDB() / setDB()
- * @var Database
+ * @var IMaintainableDatabase
*/
private $mDb = null;
* @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,
* @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' );
* @return int
*/
public function getDbType() {
- return Maintenance::DB_STD;
+ return self::DB_STD;
}
/**
* @param integer $db DB index (DB_REPLICA/DB_MASTER)
* @param array $groups; default: empty array
* @param string|bool $wiki; default: current wiki
- * @return Database
+ * @return IMaintainableDatabase
*/
protected function getDB( $db, $groups = [], $wiki = false ) {
if ( is_null( $this->mDb ) ) {
/**
* 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;
/**
* Lock the search index
- * @param Database &$db
+ * @param IMaintainableDatabase &$db
*/
private function lockSearchindex( $db ) {
$write = [ 'searchindex' ];
/**
* Unlock the tables
- * @param Database &$db
+ * @param IMaintainableDatabase &$db
*/
private function unlockSearchindex( $db ) {
$db->unlockTables( __CLASS__ . '::' . __METHOD__ );
/**
* 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 );
* 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 ) {
/**
* 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
*/