MediaWiki REL1_33
7zip.inc
Go to the documentation of this file.
1<?php
28
37 protected $stream;
38
39 private function stripPath( $path ) {
40 $prefix = 'mediawiki.compress.7z://';
41
42 return substr( $path, strlen( $prefix ) );
43 }
44
45 function stream_open( $path, $mode, $options, &$opened_path ) {
46 if ( $mode[0] == 'r' ) {
47 $options = 'e -bd -so';
48 } elseif ( $mode[0] == 'w' ) {
49 $options = 'a -bd -si';
50 } else {
51 return false;
52 }
53 $arg = Shell::escape( $this->stripPath( $path ) );
54 $command = "7za $options $arg";
55 if ( !wfIsWindows() ) {
56 // Suppress the stupid messages on stderr
57 $command .= ' 2>/dev/null';
58 }
59 $this->stream = popen( $command, $mode[0] ); // popen() doesn't like two-letter modes
60 return ( $this->stream !== false );
61 }
62
63 function url_stat( $path, $flags ) {
64 return stat( $this->stripPath( $path ) );
65 }
66
67 // This is all so lame; there should be a default class we can extend
68
69 function stream_close() {
70 return fclose( $this->stream );
71 }
72
73 function stream_flush() {
74 return fflush( $this->stream );
75 }
76
77 function stream_read( $count ) {
78 return fread( $this->stream, $count );
79 }
80
81 function stream_write( $data ) {
82 return fwrite( $this->stream, $data );
83 }
84
85 function stream_tell() {
86 return ftell( $this->stream );
87 }
88
89 function stream_eof() {
90 return feof( $this->stream );
91 }
92
93 function stream_seek( $offset, $whence ) {
94 return fseek( $this->stream, $offset, $whence );
95 }
96}
97
98stream_wrapper_register( 'mediawiki.compress.7z', SevenZipStream::class );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfIsWindows()
Check if the operating system is Windows.
$command
Definition cdb.php:65
Executes shell commands.
Definition Shell.php:44
Stream wrapper around 7za filter program.
Definition 7zip.inc:36
stream_write( $data)
Definition 7zip.inc:81
stripPath( $path)
Definition 7zip.inc:39
stream_open( $path, $mode, $options, &$opened_path)
Definition 7zip.inc:45
stream_read( $count)
Definition 7zip.inc:77
url_stat( $path, $flags)
Definition 7zip.inc:63
stream_seek( $offset, $whence)
Definition 7zip.inc:93
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1999
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37