MediaWiki REL1_37
DumpPipeOutput.php
Go to the documentation of this file.
1<?php
29
35 protected $command;
37 protected $filename;
39 protected $procOpenResource = false;
40
45 public function __construct( $command, $file = null ) {
46 if ( $file !== null ) {
47 $command .= " > " . Shell::escape( $file );
48 }
49
50 $this->startCommand( $command );
51 $this->command = $command;
52 $this->filename = $file;
53 }
54
58 public function writeCloseStream( $string ) {
59 parent::writeCloseStream( $string );
60 if ( $this->procOpenResource ) {
61 proc_close( $this->procOpenResource );
62 $this->procOpenResource = false;
63 }
64 }
65
69 public function startCommand( $command ) {
70 $spec = [
71 0 => [ "pipe", "r" ],
72 ];
73 $pipes = [];
74 $this->procOpenResource = proc_open( $command, $spec, $pipes );
75 $this->handle = $pipes[0];
76 }
77
81 public function closeRenameAndReopen( $newname ) {
82 $this->closeAndRename( $newname, true );
83 }
84
88 public function closeAndRename( $newname, $open = false ) {
89 $newname = $this->checkRenameArgCount( $newname );
90 if ( $newname ) {
91 if ( $this->handle ) {
92 fclose( $this->handle );
93 $this->handle = false;
94 }
95 if ( $this->procOpenResource ) {
96 proc_close( $this->procOpenResource );
97 $this->procOpenResource = false;
98 }
99 $this->renameOrException( $newname );
100 if ( $open ) {
102 $command .= " > " . Shell::escape( $this->filename );
103 $this->startCommand( $command );
104 }
105 }
106 }
107}
checkRenameArgCount( $newname)
renameOrException( $newname)
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...
writeCloseStream( $string)
startCommand( $command)
__construct( $command, $file=null)
closeRenameAndReopen( $newname)
Close the old file, move it to a specified name, and reopen new file with the old name....
string null $filename
resource false $procOpenResource
Executes shell commands.
Definition Shell.php:45
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition router.php:42