* @ingroup Maintenance
*/
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+require_once( __DIR__ . '/Maintenance.php' );
define( 'MW_UPGRADE_COPY', false );
define( 'MW_UPGRADE_ENCODE', true );
* @ingroup Maintenance
*/
class FiveUpgrade extends Maintenance {
+
+ /**
+ * @var DatabaseBase
+ */
+ protected $db;
+
function __construct() {
parent::__construct();
$this->cleanupSwaps = array();
$this->emailAuth = false; # don't preauthenticate emails
- $this->maxLag = 10; # if slaves are lagged more than 10 secs, wait
$this->step = $this->getOption( 'step', null );
}
/**
* Open a connection to the master server with the admin rights.
- * @return Database
+ * @return DatabaseBase
* @access private
*/
function newConnection() {
* Open a second connection to the master server, with buffering off.
* This will let us stream large datasets in and write in chunks on the
* other end.
- * @return Database
+ * @return DatabaseBase
* @access private
*/
function streamConnection() {
$this->chunkSize = $chunksize;
$this->chunkFinal = $final;
$this->chunkCount = 0;
- $this->chunkStartTime = wfTime();
+ $this->chunkStartTime = microtime( true );
$this->chunkOptions = array( 'IGNORE' );
$this->chunkTable = $table;
$this->chunkFunction = $fname;
$this->insertChunk( $chunk );
$this->chunkCount += count( $chunk );
- $now = wfTime();
+ $now = microtime( true );
$delta = $now - $this->chunkStartTime;
$rate = $this->chunkCount / $delta;
*/
function insertChunk( &$chunk ) {
// Give slaves a chance to catch up
- wfWaitForSlaves( $this->maxLag );
+ wfWaitForSlaves();
$this->dbw->insert( $this->chunkTable, $chunk, $this->chunkFunction, $this->chunkOptions );
}
/**
* Helper function for copyTable array_filter
+ * @param $x
+ * @return bool
*/
static private function notUpgradeNull( $x ) {
return $x !== MW_UPGRADE_NULL;
* MW_UPGRADE_COPY - straight copy
* MW_UPGRADE_ENCODE - for old Latin1 wikis, conv to UTF-8
* MW_UPGRADE_NULL - just put NULL
- * @param callable $callback An optional callback to modify the data
+ * @param $callback callback An optional callback to modify the data
* or perform other processing. Func should be
* ( object $row, array $copy ) and return $copy
* @access private
* Rename a given image or archived image file to the converted filename,
* leaving a symlink for URL compatibility.
*
- * @param string $oldname pre-conversion filename
- * @param string $basename pre-conversion base filename for dir hashing, if an archive
+ * @param $oldname string pre-conversion filename
+ * @param $subdirCallback string
+ * @param $basename string pre-conversion base filename for dir hashing, if an archive
+ * @return bool|string
* @access private
*/
function renameFile( $oldname, $subdirCallback = 'wfImageDir', $basename = null ) {
}
$maintClass = 'FiveUpgrade';
-require( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );