Index: branches/REL1_15/phase3/includes/filerepo/FileRepo.php |
— | — | @@ -517,47 +517,14 @@ |
518 | 518 | function cleanupDeletedBatch( $storageKeys ) {} |
519 | 519 | |
520 | 520 | /** |
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 |
522 | 524 | * |
523 | 525 | * @param Title $title Title of image |
524 | 526 | */ |
525 | 527 | 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; |
562 | 529 | } |
563 | 530 | |
564 | 531 | /** |
Index: branches/REL1_15/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. |