r52009 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52008‎ | r52009 | r52010 >
Date:22:48, 16 June 2009
Author:simetrical
Status:deferred (Comments)
Tags:
Comment:
Backport r49655, fatal errors for some users

I have not tested that this is safe, beyond php -l. However, ZeiP on
IRC reported that it fixed his fatals errors and seemed to work.

Original summary:

Move checkRedirect() from FileRepo to LocalRepo, leaving only a stub
behind. It's inappropriate for FileRepo to be accessing the database or
memcached, this is exclusively a job for a subclass. Avoids error "Call
to undefined method <class>::getArticleID()" whenever anyone uses a repo
which is not derived from LocalRepo, such as FSRepo or ForeignAPIRepo.
Modified paths:
  • /branches/REL1_15/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /branches/REL1_15/phase3/includes/filerepo/LocalRepo.php (modified) (history)

Diff [purge]

Index: branches/REL1_15/phase3/includes/filerepo/FileRepo.php
@@ -517,47 +517,14 @@
518518 function cleanupDeletedBatch( $storageKeys ) {}
519519
520520 /**
521 - * Checks if there is a redirect named as $title
 521+ * Checks if there is a redirect named as $title. If there is, return the
 522+ * title object. If not, return false.
 523+ * STUB
522524 *
523525 * @param Title $title Title of image
524526 */
525527 function checkRedirect( $title ) {
526 - global $wgMemc;
527 -
528 - if( is_string( $title ) ) {
529 - $title = Title::newFromTitle( $title );
530 - }
531 - if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) {
532 - $title = Title::makeTitle( NS_FILE, $title->getText() );
533 - }
534 -
535 - $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
536 - $cachedValue = $wgMemc->get( $memcKey );
537 - if( $cachedValue ) {
538 - return Title::newFromDbKey( $cachedValue );
539 - } elseif( $cachedValue == ' ' ) { # FIXME: ugly hack, but BagOStuff caching seems to be weird and return false if !cachedValue, not only if it doesn't exist
540 - return false;
541 - }
542 -
543 - $id = $this->getArticleID( $title );
544 - if( !$id ) {
545 - $wgMemc->set( $memcKey, " ", 9000 );
546 - return false;
547 - }
548 - $dbr = $this->getSlaveDB();
549 - $row = $dbr->selectRow(
550 - 'redirect',
551 - array( 'rd_title', 'rd_namespace' ),
552 - array( 'rd_from' => $id ),
553 - __METHOD__
554 - );
555 -
556 - if( $row ) $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title );
557 - $wgMemc->set( $memcKey, ($row ? $targetTitle->getPrefixedDBkey() : " "), 9000 );
558 - if( !$row ) {
559 - return false;
560 - }
561 - return $targetTitle;
 528+ return false;
562529 }
563530
564531 /**
Index: branches/REL1_15/phase3/includes/filerepo/LocalRepo.php
@@ -67,7 +67,52 @@
6868 }
6969 return $status;
7070 }
 71+
 72+ /**
 73+ * Checks if there is a redirect named as $title
 74+ *
 75+ * @param Title $title Title of image
 76+ */
 77+ function checkRedirect( $title ) {
 78+ global $wgMemc;
7179
 80+ if( is_string( $title ) ) {
 81+ $title = Title::newFromTitle( $title );
 82+ }
 83+ if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) {
 84+ $title = Title::makeTitle( NS_FILE, $title->getText() );
 85+ }
 86+
 87+ $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
 88+ $cachedValue = $wgMemc->get( $memcKey );
 89+ if( $cachedValue ) {
 90+ return Title::newFromDbKey( $cachedValue );
 91+ } elseif( $cachedValue == ' ' ) { # FIXME: ugly hack, but BagOStuff caching seems to be weird and return false if !cachedValue, not only if it doesn't exist
 92+ return false;
 93+ }
 94+
 95+ $id = $this->getArticleID( $title );
 96+ if( !$id ) {
 97+ $wgMemc->set( $memcKey, " ", 9000 );
 98+ return false;
 99+ }
 100+ $dbr = $this->getSlaveDB();
 101+ $row = $dbr->selectRow(
 102+ 'redirect',
 103+ array( 'rd_title', 'rd_namespace' ),
 104+ array( 'rd_from' => $id ),
 105+ __METHOD__
 106+ );
 107+
 108+ if( $row ) $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title );
 109+ $wgMemc->set( $memcKey, ($row ? $targetTitle->getPrefixedDBkey() : " "), 9000 );
 110+ if( !$row ) {
 111+ return false;
 112+ }
 113+ return $targetTitle;
 114+ }
 115+
 116+
72117 /**
73118 * Function link Title::getArticleID().
74119 * We can't say Title object, what database it should use, so we duplicate that function here.

Follow-up revisions

RevisionCommit summaryAuthorDate
r53179* Updates for 1.15.1...tstarling16:47, 13 July 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49655Move checkRedirect() from FileRepo to LocalRepo, leaving only a stub behind. ...tstarling03:06, 20 April 2009

Comments

#Comment by Enriluis (talk | contribs)   18:04, 24 June 2009

$wgHTTPTimeout by default is 3 milliseconds , i had increase this value , but the response of pages are slow while the thumbs images are downloading , and sometimes when reached this time the the page go blank and no result. how to make the page show first, and them images thumb show while we are reading the page or article.?

#Comment by Tim Starling (talk | contribs)   16:35, 13 July 2009

Missing release notes.

Status & tagging log