r16548 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16547‎ | r16548 | r16549 >
Date:17:52, 18 September 2006
Author:brion
Status:old
Tags:
Comment:
* Lazy extraction of text chunks in Revision objects, may reduce hits to
external storage when actual text content is not used
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Revision.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Revision.php
@@ -259,10 +259,13 @@
260260 $this->mTitle = null;
261261 }
262262
 263+ // Lazy extraction...
 264+ $this->mText = null;
263265 if( isset( $row->old_text ) ) {
264 - $this->mText = $this->getRevisionText( $row );
 266+ $this->mTextRow = $row;
265267 } else {
266 - $this->mText = null;
 268+ // 'text' table row entry will be lazy-loaded
 269+ $this->mTextRow = null;
267270 }
268271 } elseif( is_array( $row ) ) {
269272 // Build a new revision to be saved...
@@ -668,14 +671,22 @@
669672 function loadText() {
670673 $fname = 'Revision::loadText';
671674 wfProfileIn( $fname );
 675+
 676+ // If we kept data for lazy extraction, use it now...
 677+ $row = $this->mTextRow;
 678+ $this->mTextRow = null;
 679+
 680+ if( !$row ) {
 681+ // Text data is immutable; check slaves first.
 682+ $dbr =& wfGetDB( DB_SLAVE );
 683+ $row = $dbr->selectRow( 'text',
 684+ array( 'old_text', 'old_flags' ),
 685+ array( 'old_id' => $this->getTextId() ),
 686+ $fname);
 687+ }
672688
673 - $dbr =& wfGetDB( DB_SLAVE );
674 - $row = $dbr->selectRow( 'text',
675 - array( 'old_text', 'old_flags' ),
676 - array( 'old_id' => $this->getTextId() ),
677 - $fname);
678 -
679689 if( !$row ) {
 690+ // Possible slave lag!
680691 $dbw =& wfGetDB( DB_MASTER );
681692 $row = $dbw->selectRow( 'text',
682693 array( 'old_text', 'old_flags' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -208,6 +208,8 @@
209209 * (bug 7309) Plurals: use singular form for zero in French and Brazilian Portuguese
210210 * Add page_no_title_convert field to support language variant conversion
211211 for page titles which shouldn't be converted on display/linking
 212+* Lazy extraction of text chunks in Revision objects, may reduce hits to
 213+ external storage when actual text content is not used
212214
213215
214216 == Languages updated ==