MediaWiki master
Dump7ZipOutput.php
Go to the documentation of this file.
1<?php
12namespace MediaWiki\Export;
13
15
24
29 public function __construct( $file, $cmpLevel = 4 ) {
30 $this->compressionLevel = $cmpLevel;
31 $command = $this->setup7zCommand( $file );
32 parent::__construct( $command );
33 $this->filename = $file;
34 }
35
40 private function setup7zCommand( $file ) {
41 $command = "7za a -bd -si -mx=";
42 $command .= Shell::escape( (string)$this->compressionLevel ) . ' ';
43 $command .= Shell::escape( $file );
44 // Suppress annoying useless crap from p7zip
45 // Unfortunately this could suppress real error messages too
46 $command .= ' >' . wfGetNull() . ' 2>&1';
47 return $command;
48 }
49
53 public function closeAndRename( $newname, $open = false ) {
54 $newname = $this->checkRenameArgCount( $newname );
55 if ( $newname ) {
56 fclose( $this->handle );
57 proc_close( $this->procOpenResource );
58 $this->renameOrException( $newname );
59 if ( $open ) {
60 $command = $this->setup7zCommand( $this->filename );
61 $this->startCommand( $command );
62 }
63 }
64 }
65}
66
68class_alias( Dump7ZipOutput::class, 'Dump7ZipOutput' );
wfGetNull()
Get a platform-independent path to the null file, e.g.
__construct( $file, $cmpLevel=4)
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...
Executes shell commands.
Definition Shell.php:32