Index: trunk/phase3/includes/filerepo/FileRepo.php |
— | — | @@ -518,47 +518,14 @@ |
519 | 519 | function cleanupDeletedBatch( $storageKeys ) {} |
520 | 520 | |
521 | 521 | /** |
522 | | - * Checks if there is a redirect named as $title |
| 522 | + * Checks if there is a redirect named as $title. If there is, return the |
| 523 | + * title object. If not, return false. |
| 524 | + * STUB |
523 | 525 | * |
524 | 526 | * @param Title $title Title of image |
525 | 527 | */ |
526 | 528 | function checkRedirect( $title ) { |
527 | | - global $wgMemc; |
528 | | - |
529 | | - if( is_string( $title ) ) { |
530 | | - $title = Title::newFromTitle( $title ); |
531 | | - } |
532 | | - if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) { |
533 | | - $title = Title::makeTitle( NS_FILE, $title->getText() ); |
534 | | - } |
535 | | - |
536 | | - $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) ); |
537 | | - $cachedValue = $wgMemc->get( $memcKey ); |
538 | | - if( $cachedValue ) { |
539 | | - return Title::newFromDbKey( $cachedValue ); |
540 | | - } elseif( $cachedValue == ' ' ) { # FIXME: ugly hack, but BagOStuff caching seems to be weird and return false if !cachedValue, not only if it doesn't exist |
541 | | - return false; |
542 | | - } |
543 | | - |
544 | | - $id = $this->getArticleID( $title ); |
545 | | - if( !$id ) { |
546 | | - $wgMemc->set( $memcKey, " ", 9000 ); |
547 | | - return false; |
548 | | - } |
549 | | - $dbr = $this->getSlaveDB(); |
550 | | - $row = $dbr->selectRow( |
551 | | - 'redirect', |
552 | | - array( 'rd_title', 'rd_namespace' ), |
553 | | - array( 'rd_from' => $id ), |
554 | | - __METHOD__ |
555 | | - ); |
556 | | - |
557 | | - if( $row ) $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title ); |
558 | | - $wgMemc->set( $memcKey, ($row ? $targetTitle->getPrefixedDBkey() : " "), 9000 ); |
559 | | - if( !$row ) { |
560 | | - return false; |
561 | | - } |
562 | | - return $targetTitle; |
| 529 | + return false; |
563 | 530 | } |
564 | 531 | |
565 | 532 | /** |
Index: trunk/phase3/includes/filerepo/LocalRepo.php |
— | — | @@ -67,7 +67,52 @@ |
68 | 68 | } |
69 | 69 | return $status; |
70 | 70 | } |
| 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; |
71 | 79 | |
| 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 | + |
72 | 117 | /** |
73 | 118 | * Function link Title::getArticleID(). |
74 | 119 | * We can't say Title object, what database it should use, so we duplicate that function here. |