Index: trunk/phase3/maintenance/storage/dumpRev.php |
— | — | @@ -6,13 +6,51 @@ |
7 | 7 | |
8 | 8 | require_once( dirname(__FILE__) . '/../commandLine.inc' ); |
9 | 9 | |
| 10 | +$wgDebugLogFile = '/dev/stdout'; |
| 11 | + |
| 12 | + |
10 | 13 | $dbr = wfGetDB( DB_SLAVE ); |
11 | | -$row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $args[0] ) ); |
12 | | -$obj = unserialize( $row->old_text ); |
| 14 | +$row = $dbr->selectRow( |
| 15 | + array( 'text', 'revision' ), |
| 16 | + array( 'old_flags', 'old_text' ), |
| 17 | + array( 'old_id=rev_text_id', 'rev_id' => $args[0] ) |
| 18 | +); |
| 19 | +if ( !$row ) { |
| 20 | + print "Row not found\n"; |
| 21 | + exit; |
| 22 | +} |
13 | 23 | |
14 | | -if ( get_class( $obj ) == 'concatenatedgziphistoryblob' ) { |
15 | | - print_r( array_keys( $obj->mItems ) ); |
| 24 | +$flags = explode( ',', $row->old_flags ); |
| 25 | +$text = $row->old_text; |
| 26 | +if ( in_array( 'external', $flags ) ) { |
| 27 | + print "External $text\n"; |
| 28 | + if ( preg_match( '!^DB://(\w+)/(\w+)/(\w+)$!', $text, $m ) ) { |
| 29 | + $es = ExternalStore::getStoreObject( 'DB' ); |
| 30 | + $blob = $es->fetchBlob( $m[1], $m[2], $m[3] ); |
| 31 | + if ( strtolower( get_class( $blob ) ) == 'concatenatedgziphistoryblob' ) { |
| 32 | + print "Found external CGZ\n"; |
| 33 | + $blob->uncompress(); |
| 34 | + print "Items: (" . implode( ', ', array_keys( $blob->mItems ) ) . ")\n"; |
| 35 | + $text = $blob->getItem( $m[3] ); |
| 36 | + } else { |
| 37 | + print "CGZ expected at $text, got " . gettype( $blob ) . "\n"; |
| 38 | + $text = $blob; |
| 39 | + } |
| 40 | + } else { |
| 41 | + print "External plain $text\n"; |
| 42 | + $text = ExternalStore::fetchFromURL( $text ); |
| 43 | + } |
| 44 | +} |
| 45 | +if ( in_array( 'gzip', $flags ) ) { |
| 46 | + $text = gzinflate( $text ); |
| 47 | +} |
| 48 | +if ( in_array( 'object', $flags ) ) { |
| 49 | + $text = unserialize( $text ); |
| 50 | +} |
| 51 | + |
| 52 | +if ( is_object( $text ) ) { |
| 53 | + print "Unexpectedly got object of type: " . get_class( $text ) . "\n"; |
16 | 54 | } else { |
17 | | - var_dump( $obj ); |
| 55 | + print "Text length: " . strlen( $text ) ."\n"; |
| 56 | + print substr( $text, 0, 100 ) . "\n"; |
18 | 57 | } |
19 | | - |