MediaWiki  1.33.0
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 
98 stream_wrapper_register( 'mediawiki.compress.7z', SevenZipStream::class );
SevenZipStream\$stream
$stream
Definition: 7zip.inc:37
MediaWiki\Shell\Shell
Executes shell commands.
Definition: Shell.php:44
php
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:35
$data
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Definition: generatePhpCharToUpperMappings.php:13
SevenZipStream\stream_write
stream_write( $data)
Definition: 7zip.inc:81
SevenZipStream\stream_read
stream_read( $count)
Definition: 7zip.inc:77
SevenZipStream\stream_seek
stream_seek( $offset, $whence)
Definition: 7zip.inc:93
SevenZipStream\stripPath
stripPath( $path)
Definition: 7zip.inc:39
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
SevenZipStream\stream_open
stream_open( $path, $mode, $options, &$opened_path)
Definition: 7zip.inc:45
SevenZipStream\url_stat
url_stat( $path, $flags)
Definition: 7zip.inc:63
SevenZipStream\stream_close
stream_close()
Definition: 7zip.inc:69
$command
$command
Definition: cdb.php:65
wfIsWindows
wfIsWindows()
Check if the operating system is Windows.
Definition: GlobalFunctions.php:1951
$options
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:1985
$path
$path
Definition: NoLocalSettings.php:25
SevenZipStream
Stream wrapper around 7za filter program.
Definition: 7zip.inc:36
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
SevenZipStream\stream_tell
stream_tell()
Definition: 7zip.inc:85
SevenZipStream\stream_flush
stream_flush()
Definition: 7zip.inc:73
SevenZipStream\stream_eof
stream_eof()
Definition: 7zip.inc:89