MediaWiki  master
Dump7ZipOutput.php
Go to the documentation of this file.
1 <?php
27 
35  protected $compressionLevel;
36 
41  public function __construct( $file, $cmpLevel = 4 ) {
42  $this->compressionLevel = $cmpLevel;
43  $command = $this->setup7zCommand( $file );
44  parent::__construct( $command );
45  $this->filename = $file;
46  }
47 
52  private function setup7zCommand( $file ) {
53  $command = "7za a -bd -si -mx=";
54  $command .= Shell::escape( $this->compressionLevel ) . ' ';
55  $command .= Shell::escape( $file );
56  // Suppress annoying useless crap from p7zip
57  // Unfortunately this could suppress real error messages too
58  $command .= ' >' . wfGetNull() . ' 2>&1';
59  return $command;
60  }
61 
65  public function closeAndRename( $newname, $open = false ) {
66  $newname = $this->checkRenameArgCount( $newname );
67  if ( $newname ) {
68  fclose( $this->handle );
69  proc_close( $this->procOpenResource );
70  $this->renameOrException( $newname );
71  if ( $open ) {
72  $command = $this->setup7zCommand( $this->filename );
73  $this->startCommand( $command );
74  }
75  }
76  }
77 }
MediaWiki\Shell\Shell
Executes shell commands.
Definition: Shell.php:44
Dump7ZipOutput\__construct
__construct( $file, $cmpLevel=4)
Definition: Dump7ZipOutput.php:41
DumpFileOutput\checkRenameArgCount
checkRenameArgCount( $newname)
Definition: DumpFileOutput.php:83
DumpPipeOutput\startCommand
startCommand( $command)
Definition: DumpPipeOutput.php:66
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
Dump7ZipOutput\setup7zCommand
setup7zCommand( $file)
Definition: Dump7ZipOutput.php:52
DumpFileOutput\renameOrException
renameOrException( $newname)
Definition: DumpFileOutput.php:72
Dump7ZipOutput\closeAndRename
closeAndRename( $newname, $open=false)
Close the old file, and move it to a specified name.Use this for the last piece of a file written out...
Definition: Dump7ZipOutput.php:65
wfGetNull
wfGetNull()
Get a platform-independent path to the null file, e.g.
Definition: GlobalFunctions.php:2582
DumpPipeOutput
Definition: DumpPipeOutput.php:33
DumpPipeOutput\$command
$command
Definition: DumpPipeOutput.php:34
Dump7ZipOutput\$compressionLevel
int $compressionLevel
Definition: Dump7ZipOutput.php:35
Dump7ZipOutput
Definition: Dump7ZipOutput.php:31