MediaWiki REL1_34
DumpPipeOutput.php
Go to the documentation of this file.
1<?php
29
34 protected $command, $filename;
36 protected $procOpenResource = false;
37
42 function __construct( $command, $file = null ) {
43 if ( !is_null( $file ) ) {
44 $command .= " > " . Shell::escape( $file );
45 }
46
47 $this->startCommand( $command );
48 $this->command = $command;
49 $this->filename = $file;
50 }
51
55 function writeCloseStream( $string ) {
56 parent::writeCloseStream( $string );
57 if ( $this->procOpenResource ) {
58 proc_close( $this->procOpenResource );
59 $this->procOpenResource = false;
60 }
61 }
62
66 function startCommand( $command ) {
67 $spec = [
68 0 => [ "pipe", "r" ],
69 ];
70 $pipes = [];
71 $this->procOpenResource = proc_open( $command, $spec, $pipes );
72 $this->handle = $pipes[0];
73 }
74
78 function closeRenameAndReopen( $newname ) {
79 $this->closeAndRename( $newname, true );
80 }
81
85 function closeAndRename( $newname, $open = false ) {
86 $newname = $this->checkRenameArgCount( $newname );
87 if ( $newname ) {
88 if ( $this->handle ) {
89 fclose( $this->handle );
90 $this->handle = false;
91 }
92 if ( $this->procOpenResource ) {
93 proc_close( $this->procOpenResource );
94 $this->procOpenResource = false;
95 }
96 $this->renameOrException( $newname );
97 if ( $open ) {
99 $command .= " > " . Shell::escape( $this->filename );
100 $this->startCommand( $command );
101 }
102 }
103 }
104}
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....
resource bool $procOpenResource
Executes shell commands.
Definition Shell.php:44
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition router.php:42