| Index: trunk/phase3/maintenance/importDump.php |
| — | — | @@ -25,6 +25,7 @@ |
| 26 | 26 | $optionsWithArgs = array( 'report' ); |
| 27 | 27 | |
| 28 | 28 | require_once( dirname(__FILE__) . '/commandLine.inc' ); |
| | 29 | +require_once( '7zip.inc' ); |
| 29 | 30 | |
| 30 | 31 | /** |
| 31 | 32 | * @ingroup Maintenance |
| — | — | @@ -115,10 +116,19 @@ |
| 116 | 117 | } |
| 117 | 118 | |
| 118 | 119 | function importFromFile( $filename ) { |
| | 120 | + $t = true; |
| 119 | 121 | if( preg_match( '/\.gz$/', $filename ) ) { |
| 120 | 122 | $filename = 'compress.zlib://' . $filename; |
| 121 | 123 | } |
| 122 | | - $file = fopen( $filename, 'rt' ); |
| | 124 | + elseif( preg_match( '/\.bz2$/', $filename ) ) { |
| | 125 | + $filename = 'compress.bzip2://' . $filename; |
| | 126 | + } |
| | 127 | + elseif( preg_match( '/\.7z$/', $filename ) ) { |
| | 128 | + $filename = 'mediawiki.compress.7z://' . $filename; |
| | 129 | + $t = false; |
| | 130 | + } |
| | 131 | + |
| | 132 | + $file = fopen( $filename, $t ? 'rt' : 't' ); //our 7zip wrapper uses popen, which seems not to like two-letter modes |
| 123 | 133 | return $this->importFromHandle( $file ); |
| 124 | 134 | } |
| 125 | 135 | |
| Index: trunk/phase3/maintenance/7zip.inc |
| — | — | @@ -0,0 +1,69 @@ |
| | 2 | +<?php |
| | 3 | +/** |
| | 4 | + * Stream wrapper around 7za filter program. |
| | 5 | + * Required since we can't pass an open file resource to XMLReader->open() |
| | 6 | + * which is used for the text prefetch. |
| | 7 | + * |
| | 8 | + * @ingroup Maintenance |
| | 9 | + */ |
| | 10 | +class SevenZipStream { |
| | 11 | + var $stream; |
| | 12 | + |
| | 13 | + private function stripPath( $path ) { |
| | 14 | + $prefix = 'mediawiki.compress.7z://'; |
| | 15 | + return substr( $path, strlen( $prefix ) ); |
| | 16 | + } |
| | 17 | + |
| | 18 | + function stream_open( $path, $mode, $options, &$opened_path ) { |
| | 19 | + if( $mode[0] == 'r' ) { |
| | 20 | + $options = 'e -bd -so'; |
| | 21 | + } elseif( $mode[0] == 'w' ) { |
| | 22 | + $options = 'a -bd -si'; |
| | 23 | + } else { |
| | 24 | + return false; |
| | 25 | + } |
| | 26 | + $arg = wfEscapeShellArg( $this->stripPath( $path ) ); |
| | 27 | + $command = "7za $options $arg"; |
| | 28 | + if( !wfIsWindows() ) { |
| | 29 | + // Suppress the stupid messages on stderr |
| | 30 | + $command .= ' 2>/dev/null'; |
| | 31 | + } |
| | 32 | + $this->stream = popen( $command, $mode ); |
| | 33 | + return ($this->stream !== false); |
| | 34 | + } |
| | 35 | + |
| | 36 | + function url_stat( $path, $flags ) { |
| | 37 | + return stat( $this->stripPath( $path ) ); |
| | 38 | + } |
| | 39 | + |
| | 40 | + // This is all so lame; there should be a default class we can extend |
| | 41 | + |
| | 42 | + function stream_close() { |
| | 43 | + return fclose( $this->stream ); |
| | 44 | + } |
| | 45 | + |
| | 46 | + function stream_flush() { |
| | 47 | + return fflush( $this->stream ); |
| | 48 | + } |
| | 49 | + |
| | 50 | + function stream_read( $count ) { |
| | 51 | + return fread( $this->stream, $count ); |
| | 52 | + } |
| | 53 | + |
| | 54 | + function stream_write( $data ) { |
| | 55 | + return fwrite( $this->stream, $data ); |
| | 56 | + } |
| | 57 | + |
| | 58 | + function stream_tell() { |
| | 59 | + return ftell( $this->stream ); |
| | 60 | + } |
| | 61 | + |
| | 62 | + function stream_eof() { |
| | 63 | + return feof( $this->stream ); |
| | 64 | + } |
| | 65 | + |
| | 66 | + function stream_seek( $offset, $whence ) { |
| | 67 | + return fseek( $this->stream, $offset, $whence ); |
| | 68 | + } |
| | 69 | +} |
| | 70 | +stream_wrapper_register( 'mediawiki.compress.7z', 'SevenZipStream' ); |
| \ No newline at end of file |
| Property changes on: trunk/phase3/maintenance/7zip.inc |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 71 | + native |
| Index: trunk/phase3/maintenance/dumpTextPass.php |
| — | — | @@ -26,79 +26,11 @@ |
| 27 | 27 | |
| 28 | 28 | require_once( dirname(__FILE__) . '/commandLine.inc' ); |
| 29 | 29 | require_once( 'backup.inc' ); |
| | 30 | +require_once( '7zip.inc' ); |
| 30 | 31 | |
| 31 | 32 | /** |
| 32 | | - * Stream wrapper around 7za filter program. |
| 33 | | - * Required since we can't pass an open file resource to XMLReader->open() |
| 34 | | - * which is used for the text prefetch. |
| 35 | | - * |
| 36 | 33 | * @ingroup Maintenance |
| 37 | 34 | */ |
| 38 | | -class SevenZipStream { |
| 39 | | - var $stream; |
| 40 | | - |
| 41 | | - private function stripPath( $path ) { |
| 42 | | - $prefix = 'mediawiki.compress.7z://'; |
| 43 | | - return substr( $path, strlen( $prefix ) ); |
| 44 | | - } |
| 45 | | - |
| 46 | | - function stream_open( $path, $mode, $options, &$opened_path ) { |
| 47 | | - if( $mode{0} == 'r' ) { |
| 48 | | - $options = 'e -bd -so'; |
| 49 | | - } elseif( $mode{0} == 'w' ) { |
| 50 | | - $options = 'a -bd -si'; |
| 51 | | - } else { |
| 52 | | - return false; |
| 53 | | - } |
| 54 | | - $arg = wfEscapeShellArg( $this->stripPath( $path ) ); |
| 55 | | - $command = "7za $options $arg"; |
| 56 | | - if( !wfIsWindows() ) { |
| 57 | | - // Suppress the stupid messages on stderr |
| 58 | | - $command .= ' 2>/dev/null'; |
| 59 | | - } |
| 60 | | - $this->stream = popen( $command, $mode ); |
| 61 | | - return ($this->stream !== false); |
| 62 | | - } |
| 63 | | - |
| 64 | | - function url_stat( $path, $flags ) { |
| 65 | | - return stat( $this->stripPath( $path ) ); |
| 66 | | - } |
| 67 | | - |
| 68 | | - // This is all so lame; there should be a default class we can extend |
| 69 | | - |
| 70 | | - function stream_close() { |
| 71 | | - return fclose( $this->stream ); |
| 72 | | - } |
| 73 | | - |
| 74 | | - function stream_flush() { |
| 75 | | - return fflush( $this->stream ); |
| 76 | | - } |
| 77 | | - |
| 78 | | - function stream_read( $count ) { |
| 79 | | - return fread( $this->stream, $count ); |
| 80 | | - } |
| 81 | | - |
| 82 | | - function stream_write( $data ) { |
| 83 | | - return fwrite( $this->stream, $data ); |
| 84 | | - } |
| 85 | | - |
| 86 | | - function stream_tell() { |
| 87 | | - return ftell( $this->stream ); |
| 88 | | - } |
| 89 | | - |
| 90 | | - function stream_eof() { |
| 91 | | - return feof( $this->stream ); |
| 92 | | - } |
| 93 | | - |
| 94 | | - function stream_seek( $offset, $whence ) { |
| 95 | | - return fseek( $this->stream, $offset, $whence ); |
| 96 | | - } |
| 97 | | -} |
| 98 | | -stream_wrapper_register( 'mediawiki.compress.7z', 'SevenZipStream' ); |
| 99 | | - |
| 100 | | -/** |
| 101 | | - * @ingroup Maintenance |
| 102 | | - */ |
| 103 | 35 | class TextPassDumper extends BackupDumper { |
| 104 | 36 | var $prefetch = null; |
| 105 | 37 | var $input = "php://stdin"; |
| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -393,6 +393,7 @@ |
| 394 | 394 | * (bug 16084) Default memory limit has be increased to 50M, see $wgMemoryLimit |
| 395 | 395 | * (bug 17864/19519) Added proper input normalization in Special:UserRights |
| 396 | 396 | * (bug 20086) Add Hook to add extra statistics at the end of Special:Statistics |
| | 397 | +* (bug 19289) importDump.php can now handle bzip2 and 7zip |
| 397 | 398 | |
| 398 | 399 | == API changes in 1.16 == |
| 399 | 400 | |