diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2008-03-21 11:49:34 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2008-03-21 11:49:34 +0100 |
commit | 086ae52d12011746a75f5588e877347bc0457352 (patch) | |
tree | e73263c7a29d0f94fafb874562610e16eb292ba8 /includes/filerepo/LocalRepo.php | |
parent | 749e7fb2bae7bbda855de3c9e319435b9f698ff7 (diff) |
Update auf MediaWiki 1.12.0
Diffstat (limited to 'includes/filerepo/LocalRepo.php')
-rw-r--r-- | includes/filerepo/LocalRepo.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 72f9e9a6..a259bd48 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -62,4 +62,52 @@ class LocalRepo extends FSRepo { } return $status; } + + /** + * Function link Title::getArticleID(). + * We can't say Title object, what database it should use, so we duplicate that function here. + */ + private function getArticleID( $title ) { + if( !$title instanceof Title ) { + return 0; + } + $dbr = $this->getSlaveDB(); + $id = $dbr->selectField( + 'page', // Table + 'page_id', //Field + array( //Conditions + 'page_namespace' => $title->getNamespace(), + 'page_title' => $title->getDbKey(), + ), + __METHOD__ //Function name + ); + return $id; + } + + function checkRedirect( $title ) { + global $wgFileRedirects; + if( !$wgFileRedirects ) { + return false; + } + + if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) { + $title = Title::makeTitle( NS_IMAGE, $title->getText() ); + } + + $id = $this->getArticleID( $title ); + if( !$id ) { + return false; + } + $dbr = $this->getSlaveDB(); + $row = $dbr->selectRow( + 'redirect', + array( 'rd_title', 'rd_namespace' ), + array( 'rd_from' => $id ), + __METHOD__ + ); + if( !$row ) { + return false; + } + return Title::makeTitle( $row->rd_namespace, $row->rd_title ); + } } |