r74253 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74252‎ | r74253 | r74254 >
Date:15:04, 4 October 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Fix issues after r54561 which avoided use of the 7z wrapper.
popen() doesn't like two-letter modes but the approach checked for it at
too high level, used as mode the letter t, not r, which was an invalid
option for SevenZipStream, and is still an invalid argument for popen.
Modified paths:
  • /trunk/phase3/maintenance/7zip.inc (modified) (history)
  • /trunk/phase3/maintenance/importDump.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/importDump.php
@@ -115,7 +115,6 @@
116116 }
117117
118118 function importFromFile( $filename ) {
119 - $t = true;
120119 if ( preg_match( '/\.gz$/', $filename ) ) {
121120 $filename = 'compress.zlib://' . $filename;
122121 }
@@ -124,10 +123,9 @@
125124 }
126125 elseif ( preg_match( '/\.7z$/', $filename ) ) {
127126 $filename = 'mediawiki.compress.7z://' . $filename;
128 - $t = false;
129127 }
130128
131 - $file = fopen( $filename, $t ? 'rt' : 't' ); // our 7zip wrapper uses popen, which seems not to like two-letter modes
 129+ $file = fopen( $filename, 'rt' );
132130 return $this->importFromHandle( $file );
133131 }
134132
Index: trunk/phase3/maintenance/7zip.inc
@@ -35,7 +35,7 @@
3636 // Suppress the stupid messages on stderr
3737 $command .= ' 2>/dev/null';
3838 }
39 - $this->stream = popen( $command, $mode );
 39+ $this->stream = popen( $command, $mode[0] ); // popen() doesn't like two-letter modes
4040 return ( $this->stream !== false );
4141 }
4242
@@ -73,4 +73,4 @@
7474 return fseek( $this->stream, $offset, $whence );
7575 }
7676 }
77 -stream_wrapper_register( 'mediawiki.compress.7z', 'SevenZipStream' );
\ No newline at end of file
 77+stream_wrapper_register( 'mediawiki.compress.7z', 'SevenZipStream' );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54561(bug 19289) importDump.php can now handle bzip2 and 7zip....emufarmers00:53, 7 August 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   05:06, 8 October 2010

Nice catch! One-letter-off typo bugs are the worst ;)

Status & tagging log