From: Brion Vibber Date: Tue, 29 Jan 2008 01:14:50 +0000 (+0000) Subject: Applying live hacks from Wikimedia code base: X-Git-Tag: 1.31.0-rc.0~49732 X-Git-Url: http://git.cyclocoop.org/%22.%24match%5B1%5D.%22?a=commitdiff_plain;h=c5c673781844cd77956ade5cbc1da9f8d96319d1;p=lhc%2Fweb%2Fwiklou.git Applying live hacks from Wikimedia code base: * Clarify profiling results for local and remote repo lookups * Use master database for critical lookups * Don't upgrade db rows when in read-only mode --- diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index d763c57c2c..3409b5b54b 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -183,7 +183,7 @@ class LocalFile extends File # Unconditionally set loaded=true, we don't want the accessors constantly rechecking $this->dataLoaded = true; - $dbr = $this->repo->getSlaveDB(); + $dbr = $this->repo->getMasterDB(); $row = $dbr->selectRow( 'image', $this->getCacheFields( 'img_' ), array( 'img_name' => $this->getName() ), $fname ); @@ -293,6 +293,9 @@ class LocalFile extends File $dbw = $this->repo->getMasterDB(); list( $major, $minor ) = self::splitMime( $this->mime ); + if ( wfReadOnly() ) { + return; + } wfDebug(__METHOD__.': upgrading '.$this->getName()." to the current schema\n"); $dbw->update( 'image', @@ -608,6 +611,9 @@ class LocalFile extends File * @public */ function nextHistoryLine() { + # Polymorphic function name to distinguish foreign and local fetches + $fname = get_class( $this ) . '::' . __FUNCTION__; + $dbr = $this->repo->getSlaveDB(); if ( $this->historyLine == 0 ) {// called for the first time, return line from cur @@ -617,7 +623,7 @@ class LocalFile extends File "'' AS oi_archive_name" ), array( 'img_name' => $this->title->getDBkey() ), - __METHOD__ + $fname ); if ( 0 == $dbr->numRows( $this->historyRes ) ) { $dbr->freeResult($this->historyRes); @@ -628,7 +634,7 @@ class LocalFile extends File $dbr->freeResult($this->historyRes); $this->historyRes = $dbr->select( 'oldimage', '*', array( 'oi_name' => $this->title->getDBkey() ), - __METHOD__, + $fname, array( 'ORDER BY' => 'oi_timestamp DESC' ) ); }