00001 <?php 00007 require_once( dirname(__FILE__) . '/../commandLine.inc' ); 00008 00009 $wgDebugLogFile = '/dev/stdout'; 00010 00011 00012 $dbr = wfGetDB( DB_SLAVE ); 00013 $row = $dbr->selectRow( 00014 array( 'text', 'revision' ), 00015 array( 'old_flags', 'old_text' ), 00016 array( 'old_id=rev_text_id', 'rev_id' => $args[0] ) 00017 ); 00018 if ( !$row ) { 00019 print "Row not found\n"; 00020 exit; 00021 } 00022 00023 $flags = explode( ',', $row->old_flags ); 00024 $text = $row->old_text; 00025 if ( in_array( 'external', $flags ) ) { 00026 print "External $text\n"; 00027 if ( preg_match( '!^DB://(\w+)/(\w+)/(\w+)$!', $text, $m ) ) { 00028 $es = ExternalStore::getStoreObject( 'DB' ); 00029 $blob = $es->fetchBlob( $m[1], $m[2], $m[3] ); 00030 if ( strtolower( get_class( $blob ) ) == 'concatenatedgziphistoryblob' ) { 00031 print "Found external CGZ\n"; 00032 $blob->uncompress(); 00033 print "Items: (" . implode( ', ', array_keys( $blob->mItems ) ) . ")\n"; 00034 $text = $blob->getItem( $m[3] ); 00035 } else { 00036 print "CGZ expected at $text, got " . gettype( $blob ) . "\n"; 00037 $text = $blob; 00038 } 00039 } else { 00040 print "External plain $text\n"; 00041 $text = ExternalStore::fetchFromURL( $text ); 00042 } 00043 } 00044 if ( in_array( 'gzip', $flags ) ) { 00045 $text = gzinflate( $text ); 00046 } 00047 if ( in_array( 'object', $flags ) ) { 00048 $text = unserialize( $text ); 00049 } 00050 00051 if ( is_object( $text ) ) { 00052 print "Unexpectedly got object of type: " . get_class( $text ) . "\n"; 00053 } else { 00054 print "Text length: " . strlen( $text ) ."\n"; 00055 print substr( $text, 0, 100 ) . "\n"; 00056 }