- $dbr =& wfGetDB( DB_SLAVE );
- $row = $dbr->selectRow( 'old', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
- if ( !$row || $row->old_flags != 'object' ) {
- return false;
- }
- $obj = unserialize( $row->old_text );
- if ( !is_object( $obj ) ) {
- $obj = unserialize( $obj );
+ $fname = 'HistoryBlobStub::getText';
+ global $wgBlobCache;
+ if( isset( $wgBlobCache[$this->mOldId] ) ) {
+ $obj = $wgBlobCache[$this->mOldId];
+ } else {
+ $dbr = wfGetDB( DB_SLAVE );
+ $row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
+ if( !$row ) {
+ return false;
+ }
+ $flags = explode( ',', $row->old_flags );
+ if( in_array( 'external', $flags ) ) {
+ $url=$row->old_text;
+ @list( /* $proto */ ,$path)=explode('://',$url,2);
+ if ($path=="") {
+ wfProfileOut( $fname );
+ return false;
+ }
+ $row->old_text=ExternalStore::fetchFromUrl($url);
+
+ }
+ if( !in_array( 'object', $flags ) ) {
+ return false;
+ }
+
+ if( in_array( 'gzip', $flags ) ) {
+ // This shouldn't happen, but a bug in the compress script
+ // may at times gzip-compress a HistoryBlob object row.
+ $obj = unserialize( gzinflate( $row->old_text ) );
+ } else {
+ $obj = unserialize( $row->old_text );
+ }
+
+ if( !is_object( $obj ) ) {
+ // Correct for old double-serialization bug.
+ $obj = unserialize( $obj );
+ }
+
+ // Save this item for reference; if pulling many
+ // items in a row we'll likely use it again.
+ $obj->uncompress();
+ $wgBlobCache = array( $this->mOldId => $obj );