MediaWiki REL1_31
DumpPipeOutput.php
Go to the documentation of this file.
1<?php
32 protected $command, $filename;
33 protected $procOpenResource = false;
34
39 function __construct( $command, $file = null ) {
40 if ( !is_null( $file ) ) {
41 $command .= " > " . wfEscapeShellArg( $file );
42 }
43
44 $this->startCommand( $command );
45 $this->command = $command;
46 $this->filename = $file;
47 }
48
52 function writeCloseStream( $string ) {
53 parent::writeCloseStream( $string );
54 if ( $this->procOpenResource ) {
55 proc_close( $this->procOpenResource );
56 $this->procOpenResource = false;
57 }
58 }
59
63 function startCommand( $command ) {
64 $spec = [
65 0 => [ "pipe", "r" ],
66 ];
67 $pipes = [];
68 $this->procOpenResource = proc_open( $command, $spec, $pipes );
69 $this->handle = $pipes[0];
70 }
71
75 function closeRenameAndReopen( $newname ) {
76 $this->closeAndRename( $newname, true );
77 }
78
83 function closeAndRename( $newname, $open = false ) {
84 $newname = $this->checkRenameArgCount( $newname );
85 if ( $newname ) {
86 if ( $this->handle ) {
87 fclose( $this->handle );
88 $this->handle = false;
89 }
90 if ( $this->procOpenResource ) {
91 proc_close( $this->procOpenResource );
92 $this->procOpenResource = false;
93 }
94 $this->renameOrException( $newname );
95 if ( $open ) {
97 $command .= " > " . wfEscapeShellArg( $this->filename );
98 $this->startCommand( $command );
99 }
100 }
101 }
102}
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
checkRenameArgCount( $newname)
renameOrException( $newname)
closeAndRename( $newname, $open=false)
writeCloseStream( $string)
startCommand( $command)
__construct( $command, $file=null)
closeRenameAndReopen( $newname)