* Lazy extraction of text chunks in Revision objects, may reduce hits to
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 18 Sep 2006 17:52:44 +0000 (17:52 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 18 Sep 2006 17:52:44 +0000 (17:52 +0000)
  external storage when actual text content is not used

RELEASE-NOTES
includes/Revision.php

index 0dbd206..b484337 100644 (file)
@@ -208,6 +208,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 7309) Plurals: use singular form for zero in French and Brazilian Portuguese
 * Add page_no_title_convert field to support language variant conversion
   for page titles which shouldn't be converted on display/linking
+* Lazy extraction of text chunks in Revision objects, may reduce hits to
+  external storage when actual text content is not used
 
 
 == Languages updated ==
index a33e48f..8591dc1 100644 (file)
@@ -259,10 +259,13 @@ class Revision {
                                $this->mTitle = null;
                        }
 
+                       // Lazy extraction...
+                       $this->mText      = null;
                        if( isset( $row->old_text ) ) {
-                               $this->mText  = $this->getRevisionText( $row );
+                               $this->mTextRow = $row;
                        } else {
-                               $this->mText  = null;
+                               // 'text' table row entry will be lazy-loaded
+                               $this->mTextRow = null;
                        }
                } elseif( is_array( $row ) ) {
                        // Build a new revision to be saved...
@@ -668,14 +671,22 @@ class Revision {
        function loadText() {
                $fname = 'Revision::loadText';
                wfProfileIn( $fname );
-
-               $dbr =& wfGetDB( DB_SLAVE );
-               $row = $dbr->selectRow( 'text',
-                       array( 'old_text', 'old_flags' ),
-                       array( 'old_id' => $this->getTextId() ),
-                       $fname);
+               
+               // If we kept data for lazy extraction, use it now...
+               $row = $this->mTextRow;
+               $this->mTextRow = null;
+               
+               if( !$row ) {
+                       // Text data is immutable; check slaves first.
+                       $dbr =& wfGetDB( DB_SLAVE );
+                       $row = $dbr->selectRow( 'text',
+                               array( 'old_text', 'old_flags' ),
+                               array( 'old_id' => $this->getTextId() ),
+                               $fname);
+               }
 
                if( !$row ) {
+                       // Possible slave lag!
                        $dbw =& wfGetDB( DB_MASTER );
                        $row = $dbw->selectRow( 'text',
                                array( 'old_text', 'old_flags' ),