45 parent::__construct(
$title );
55 $this->mFileLoaded =
true;
62 $services = MediaWikiServices::getInstance();
63 if ( $this->mFileLoaded ) {
67 $this->mFile = $services->getRepoGroup()->findFile( $this->mTitle );
68 if ( !$this->mFile ) {
69 $this->mFile = $services->getRepoGroup()->getLocalRepo()
70 ->newFile( $this->mTitle );
73 if ( !$this->mFile instanceof
File ) {
74 throw new RuntimeException(
'Expected to find file. See T250767' );
77 $this->mRepo = $this->mFile->getRepo();
78 $this->mFileLoaded =
true;
87 if ( $this->mFile->isLocal() ) {
88 return parent::getRedirectTarget();
91 $from = $this->mFile->getRedirected();
92 $to = $this->mFile->getName();
105 if ( $this->mFile->isLocal() ) {
106 return parent::followRedirect();
108 $from = $this->mFile->getRedirected();
109 $to = $this->mFile->getName();
110 if ( $from == $to ) {
121 if ( $this->mFile->isLocal() ) {
122 return parent::isRedirect();
125 return (
bool)$this->mFile->getRedirected();
133 return $this->mFile->isLocal();
149 if ( $this->mDupes !==
null ) {
150 return $this->mDupes;
152 $hash = $this->mFile->getSha1();
155 return $this->mDupes;
157 $dupes = MediaWikiServices::getInstance()->getRepoGroup()->findBySha1( $hash );
159 $self = $this->mFile->getRepoName() .
':' . $this->mFile->getName();
160 $size = $this->mFile->getSize();
165 foreach ( $dupes as $index =>
$file ) {
166 $key =
$file->getRepoName() .
':' .
$file->getName();
167 if ( $key ==
$self ) {
168 unset( $dupes[$index] );
170 if (
$file->getSize() != $size ) {
171 unset( $dupes[$index] );
174 $this->mDupes = $dupes;
175 return $this->mDupes;
185 if ( $this->mFile->exists() ) {
186 wfDebug(
'ImagePage::doPurge purging ' . $this->mFile->getName() );
190 [
'causeAction' =>
'file-purge' ]
192 MediaWikiServices::getInstance()->getJobQueueGroup()->lazyPush(
$job );
194 wfDebug(
'ImagePage::doPurge no image for '
195 . $this->mFile->getName() .
"; limiting purge to cache only" );
202 $this->mFile->purgeCache( [
'forThumbRefresh' =>
true ] );
205 foreach ( $this->mFile->getHistory() as $oldFile ) {
206 $oldFile->purgeCache( [
'forThumbRefresh' =>
true ] );
209 if ( $this->mRepo ) {
211 $this->mRepo->invalidateImageRedirect( $this->mTitle );
214 return parent::doPurge();
229 $file = $this->mFile;
232 wfDebug( __METHOD__ .
" is not supported for this file" );
237 $repo =
$file->getRepo();
238 $dbr = $repo->getReplicaDB();
241 [
'page',
'categorylinks' ],
243 'page_title' =>
'cl_to',
247 'page_namespace' =>
$title->getNamespace(),
248 'page_title' =>
$title->getDBkey(),
252 [
'categorylinks' => [
'JOIN',
'page_id = cl_from' ] ]
255 return TitleArray::newFromResult(
$res );
263 return $this->
getFile()->getRepo()->getDisplayName();
271 return $this->
getFile()->getDescriptionUrl();
279 if (
$file->exists() &&
$file->isLocal() && !
$file->getRedirected() ) {
281 return [
'delete' => FileDeleteAction::class ] + parent::getActionOverrides();
284 return parent::getActionOverrides();
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
getFile()
Get the file for this page, if one exists.
Implements some public methods and some protected utility functions which are required by multiple ch...
static newForBacklinks(PageReference $page, $table, $params=[])
Local file in the wiki's own database.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Special handling for representing file pages.
getActionOverrides()
Move this UI stuff somewhere elseContentHandler::getActionOverrides array
doPurge()
Override handling of action=purge.
getForeignCategories()
Get the categories this file is a member of on the wiki where it was uploaded.
Base representation for an editable wiki page.
Title null $mRedirectTarget
The cache of the redirect target.
if(count( $args)< 1) $job
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.