var $fileFromRowFactory = array( 'LocalFile', 'newFromRow' );
var $oldFileFromRowFactory = array( 'OldLocalFile', 'newFromRow' );
- function getSlaveDB() {
- return wfGetDB( DB_SLAVE );
- }
-
- function getMasterDB() {
- return wfGetDB( DB_MASTER );
- }
-
- function getMemcKey( $key ) {
- return wfWikiID( $this->getSlaveDB() ) . ":{$key}";
- }
-
function newFileFromRow( $row ) {
if ( isset( $row->img_name ) ) {
return call_user_func( $this->fileFromRowFactory, $row, $this );
}
return $status;
}
-
+
/**
- * Function link Title::getArticleID().
- * We can't say Title object, what database it should use, so we duplicate that function here.
+ * Checks if there is a redirect named as $title
+ *
+ * @param Title $title Title of image
*/
- protected 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 $wgMemc;
$title = Title::newFromTitle( $title );
}
if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) {
- $title = Title::makeTitle( NS_IMAGE, $title->getText() );
+ $title = Title::makeTitle( NS_FILE, $title->getText() );
}
$memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
return $targetTitle;
}
- function invalidateImageRedirect( $title ) {
- global $wgMemc;
- $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
- $wgMemc->delete( $memcKey );
+
+ /**
+ * Function link Title::getArticleID().
+ * We can't say Title object, what database it should use, so we duplicate that function here.
+ */
+ protected 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 findBySha1( $hash ) {
$dbr = $this->getSlaveDB();
/*
* Find many files using one query
*/
- function findFiles( $titles, $flags ) {
- // FIXME: Comply with $flags
+ function findFiles( $titles ) {
// FIXME: Only accepts a $titles array where the keys are the sanitized
// file names.