X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FbackupTextPass.inc;h=27be5fd6e2427a8a10e63d90aeb4868d6da74cfb;hb=355fdffe3eb08838e56909f7c36f6bff786c8b94;hp=f13cb449ccdcf60e04e84c76d864b5069004b2ba;hpb=e4b551ca0e4d36b45ef6319301fa962450cc5b17;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/backupTextPass.inc b/maintenance/backupTextPass.inc index f13cb449cc..27be5fd6e2 100644 --- a/maintenance/backupTextPass.inc +++ b/maintenance/backupTextPass.inc @@ -48,6 +48,8 @@ class TextPassDumper extends BackupDumper { protected $maxConsecutiveFailedTextRetrievals = 200; protected $failureTimeout = 5; // Seconds to sleep after db failure + protected $bufferSize = 524288; // In bytes. Maximum size to read from the stub in on go. + protected $php = "php"; protected $spawn = false; @@ -186,6 +188,10 @@ class TextPassDumper extends BackupDumper { $url = $this->processFileOpt( $val, $param ); switch ( $opt ) { + case 'buffersize': + // Lower bound for xml reading buffer size is 4 KB + $this->bufferSize = max( intval( $val ), 4 * 1024 ); + break; case 'prefetch': require_once "$IP/maintenance/backupPrefetch.inc"; $this->prefetch = new BaseDump( $url ); @@ -368,12 +374,11 @@ class TextPassDumper extends BackupDumper { xml_set_character_data_handler( $parser, array( &$this, 'characterData' ) ); $offset = 0; // for context extraction on error reporting - $bufferSize = 512 * 1024; do { if ( $this->checkIfTimeExceeded() ) { $this->setTimeExceeded(); } - $chunk = fread( $input, $bufferSize ); + $chunk = fread( $input, $this->bufferSize ); if ( !xml_parse( $parser, $chunk, feof( $input ) ) ) { wfDebug( "TextDumpPass::readDump encountered XML parsing error\n" ); @@ -654,13 +659,13 @@ class TextPassDumper extends BackupDumper { } private function getTextSpawned( $id ) { - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); if ( !$this->spawnProc ) { // First time? $this->openSpawn(); } $text = $this->getTextSpawnedOnce( $id ); - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); return $text; } @@ -707,7 +712,7 @@ class TextPassDumper extends BackupDumper { } private function closeSpawn() { - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); if ( $this->spawnRead ) { fclose( $this->spawnRead ); } @@ -724,7 +729,7 @@ class TextPassDumper extends BackupDumper { pclose( $this->spawnProc ); } $this->spawnProc = false; - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); } private function getTextSpawnedOnce( $id ) { @@ -895,10 +900,10 @@ class TextPassDumper extends BackupDumper { $this->thisPage .= $data; } } - elseif ( $this->lastName == "model" ) { + elseif ( $this->lastName == "model" ) { $this->thisRevModel .= $data; } - elseif ( $this->lastName == "format" ) { + elseif ( $this->lastName == "format" ) { $this->thisRevFormat .= $data; }