r6655 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r6654‎ | r6655 | r6656 >
Date:08:49, 12 December 2004
Author:timstarling
Status:old
Tags:
Comment:
various bug fixes and modifications to cgz compression
Modified paths:
  • /branches/REL1_4/phase3/includes/HistoryBlob.php (modified) (history)
  • /branches/REL1_4/phase3/maintenance/compressOld.inc (modified) (history)
  • /branches/REL1_4/phase3/maintenance/compressOld.php (modified) (history)
  • /branches/REL1_4/phase3/maintenance/dumpRev.php (modified) (history)

Diff [purge]

Index: branches/REL1_4/phase3/maintenance/compressOld.inc
@@ -65,7 +65,8 @@
6666 $pageRes = $dbw->select( 'cur', array('cur_namespace', 'cur_title'), false, $fname );
6767
6868 # For each of those, get a list of revisions which fit the criteria
69 - $conds = array();
 69+ # No recompression, use a condition on old_flags
 70+ $conds = array("old_flags NOT LIKE '%object%'");
7071 if ( $beginDate ) {
7172 $conds[] = "old_timestamp>'" . $beginDate . "'";
7273 }
@@ -146,19 +147,12 @@
147148 $chunk->setText( $text );
148149 print '.';
149150 } else {
150 - # Don't make a stub if it's going to be longer than the article
151 - # Stubs are typically about 100 bytes
152 - if ( strlen( $text ) < 120 ) {
153 - $stub = false;
154 - print 'x';
155 - } else {
156 - $stub = $chunk->addItem( $text );
157 - $stub->setLocation( $primaryOldid );
158 - $hash = $stub->getHash();
159 - $stub = serialize( $stub );
160 - print '.';
161 - $usedChunk = true;
162 - }
 151+ $stub = $chunk->addItem( $text );
 152+ $stub->setLocation( $primaryOldid );
 153+ $hash = $stub->getHash();
 154+ $stub = serialize( $stub );
 155+ print '.';
 156+ $usedChunk = true;
163157 $stubs[$j] = $stub;
164158 }
165159 }
Index: branches/REL1_4/phase3/maintenance/dumpRev.php
@@ -1,7 +1,7 @@
22 <?
33 require_once( 'commandLine.inc' );
44 $dbr =& wfGetDB( DB_SLAVE );
5 -$row = $dbr->selectRow( 'old', array( 'old_flags', 'old_text' ), array( 'old_id' => 52 ) );
 5+$row = $dbr->selectRow( 'old', array( 'old_flags', 'old_text' ), array( 'old_id' => $args[0] ) );
66 $obj = unserialize( $row->old_text );
77 print_r( array_keys( $obj->mItems ) );
88
Index: branches/REL1_4/phase3/maintenance/compressOld.php
@@ -42,21 +42,19 @@
4343 print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
4444 die();
4545 }
46 -
4746 $defaults = array(
4847 't' => 'concat',
4948 'c' => 20,
5049 's' => 0,
5150 'f' => 3,
52 - 'h' => 100,
 51+ 'h' => 1024,
5352 'b' => '',
5453 'e' => '',
5554 );
5655
57 -$args = $args + $defaults;
58 -
59 -if ( $args['t'] != 'concat' && $args['t'] != 'gzip' ) {
60 - print "Type \"{$args['t']}\" not supported\n";
 56+$options = $options + $defaults;
 57+if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) {
 58+ print "Type \"{$options['t']}\" not supported\n";
6159 }
6260
6361 print "Depending on the size of your database this may take a while!\n";
@@ -66,10 +64,10 @@
6765 #sleep(5);
6866
6967 $success = true;
70 -if ( $args['t'] == 'concat' ) {
71 - $success = compressWithConcat( $args['s'], $args['c'], $args['f'], $args['h'], $args['b'], $args['e'] );
 68+if ( $options['t'] == 'concat' ) {
 69+ $success = compressWithConcat( $options['s'], $options['c'], $options['f'], $options['h'], $options['b'], $options['e'] );
7270 } else {
73 - compressOldPages( $args['s'] );
 71+ compressOldPages( $options['s'] );
7472 }
7573
7674 if ( $success ) {
Index: branches/REL1_4/phase3/includes/HistoryBlob.php
@@ -122,6 +122,7 @@
123123 if ( count( $this->mItems ) == 0 ) {
124124 return true;
125125 }
 126+ /*
126127 if ( !$this->mFast ) {
127128 $this->uncompress();
128129 $record = serialize( $this->mItems );
@@ -136,6 +137,13 @@
137138 }
138139 } else {
139140 return count( $this->mItems ) <= 10;
 141+ }*/
 142+
 143+ # Jamesday's idea: prevent excessive apache memory usage on decompression
 144+ if ( strlen( serialize( $this->mItems ) ) > $factorThreshold * 1024 ) {
 145+ return false;
 146+ } else {
 147+ return true;
140148 }
141149 }
142150 }

Status & tagging log