diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2009-07-13 21:58:36 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2009-07-13 21:58:36 +0200 |
commit | 5260ea4fce50f1426d9546efc2e8c3b0a62e642c (patch) | |
tree | f921b260e5bf9f96dfc8504cf920eaa5347f3f53 /includes/filerepo | |
parent | 9f38be46358e62f33ae2c556269a0223963edc26 (diff) |
upgrade to 1.15.1 (security fix)
Diffstat (limited to 'includes/filerepo')
-rw-r--r-- | includes/filerepo/FileRepo.php | 45 | ||||
-rw-r--r-- | includes/filerepo/LocalRepo.php | 49 |
2 files changed, 53 insertions, 41 deletions
diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index face1614..c9d34377 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -517,47 +517,14 @@ abstract class FileRepo { function cleanupDeletedBatch( $storageKeys ) {} /** - * Checks if there is a redirect named as $title + * Checks if there is a redirect named as $title. If there is, return the + * title object. If not, return false. + * STUB * * @param Title $title Title of image */ function checkRedirect( $title ) { - global $wgMemc; - - if( is_string( $title ) ) { - $title = Title::newFromTitle( $title ); - } - if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) { - $title = Title::makeTitle( NS_FILE, $title->getText() ); - } - - $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) ); - $cachedValue = $wgMemc->get( $memcKey ); - if( $cachedValue ) { - return Title::newFromDbKey( $cachedValue ); - } elseif( $cachedValue == ' ' ) { # FIXME: ugly hack, but BagOStuff caching seems to be weird and return false if !cachedValue, not only if it doesn't exist - return false; - } - - $id = $this->getArticleID( $title ); - if( !$id ) { - $wgMemc->set( $memcKey, " ", 9000 ); - return false; - } - $dbr = $this->getSlaveDB(); - $row = $dbr->selectRow( - 'redirect', - array( 'rd_title', 'rd_namespace' ), - array( 'rd_from' => $id ), - __METHOD__ - ); - - if( $row ) $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title ); - $wgMemc->set( $memcKey, ($row ? $targetTitle->getPrefixedDBkey() : " "), 9000 ); - if( !$row ) { - return false; - } - return $targetTitle; + return false; } /** @@ -598,4 +565,8 @@ abstract class FileRepo { function getMasterDB() { return wfGetDB( DB_MASTER ); } + + function getMemcKey( $key ) { + return wfWikiID( $this->getSlaveDB() ) . ":{$key}"; + } } diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 1ec1b9a6..c679dd98 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -10,10 +10,6 @@ class LocalRepo extends FSRepo { var $fileFromRowFactory = array( 'LocalFile', 'newFromRow' ); var $oldFileFromRowFactory = array( 'OldLocalFile', 'newFromRow' ); - function getMemcKey( $key ) { - return wfWikiID( $this->getSlaveDB() ) . ":{$key}"; - } - function newFileFromRow( $row ) { if ( isset( $row->img_name ) ) { return call_user_func( $this->fileFromRowFactory, $row, $this ); @@ -71,6 +67,51 @@ class LocalRepo extends FSRepo { } return $status; } + + /** + * Checks if there is a redirect named as $title + * + * @param Title $title Title of image + */ + function checkRedirect( $title ) { + global $wgMemc; + + if( is_string( $title ) ) { + $title = Title::newFromTitle( $title ); + } + if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) { + $title = Title::makeTitle( NS_FILE, $title->getText() ); + } + + $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) ); + $cachedValue = $wgMemc->get( $memcKey ); + if( $cachedValue ) { + return Title::newFromDbKey( $cachedValue ); + } elseif( $cachedValue == ' ' ) { # FIXME: ugly hack, but BagOStuff caching seems to be weird and return false if !cachedValue, not only if it doesn't exist + return false; + } + + $id = $this->getArticleID( $title ); + if( !$id ) { + $wgMemc->set( $memcKey, " ", 9000 ); + return false; + } + $dbr = $this->getSlaveDB(); + $row = $dbr->selectRow( + 'redirect', + array( 'rd_title', 'rd_namespace' ), + array( 'rd_from' => $id ), + __METHOD__ + ); + + if( $row ) $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title ); + $wgMemc->set( $memcKey, ($row ? $targetTitle->getPrefixedDBkey() : " "), 9000 ); + if( !$row ) { + return false; + } + return $targetTitle; + } + /** * Function link Title::getArticleID(). |