r70978 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70977‎ | r70978 | r70979 >
Date:18:43, 12 August 2010
Author:platonides
Status:ok
Tags:
Comment:
Convert $wgBlobCache into a static class member.
static members don't influence serialization.
Modified paths:
  • /trunk/phase3/includes/HistoryBlob.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HistoryBlob.php
@@ -137,20 +137,20 @@
138138 }
139139
140140
141 -/**
142 - * One-step cache variable to hold base blobs; operations that
143 - * pull multiple revisions may often pull multiple times from
144 - * the same blob. By keeping the last-used one open, we avoid
145 - * redundant unserialization and decompression overhead.
146 - */
147 -global $wgBlobCache;
148 -$wgBlobCache = array();
149141
150142
151143 /**
152144 * Pointer object for an item within a CGZ blob stored in the text table.
153145 */
154146 class HistoryBlobStub {
 147+ /**
 148+ * One-step cache variable to hold base blobs; operations that
 149+ * pull multiple revisions may often pull multiple times from
 150+ * the same blob. By keeping the last-used one open, we avoid
 151+ * redundant unserialization and decompression overhead.
 152+ */
 153+ protected static $blobCache = array();
 154+
155155 var $mOldId, $mHash, $mRef;
156156
157157 /**
@@ -185,9 +185,9 @@
186186
187187 function getText() {
188188 $fname = 'HistoryBlobStub::getText';
189 - global $wgBlobCache;
190 - if( isset( $wgBlobCache[$this->mOldId] ) ) {
191 - $obj = $wgBlobCache[$this->mOldId];
 189+
 190+ if( isset( self::$blobCache[$this->mOldId] ) ) {
 191+ $obj = self::$blobCache[$this->mOldId];
192192 } else {
193193 $dbr = wfGetDB( DB_SLAVE );
194194 $row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
@@ -225,7 +225,7 @@
226226 // Save this item for reference; if pulling many
227227 // items in a row we'll likely use it again.
228228 $obj->uncompress();
229 - $wgBlobCache = array( $this->mOldId => $obj );
 229+ self::$blobCache = array( $this->mOldId => $obj );
230230 }
231231 return $obj->getItem( $this->mHash );
232232 }

Status & tagging log