39 parent::__construct( $title );
46 $this->mFileLoaded =
true;
54 if ( $this->mFileLoaded ) {
58 $this->mFile = $services->getRepoGroup()->findFile( $this->mTitle );
59 if ( !$this->mFile ) {
60 $this->mFile = $services->getRepoGroup()->getLocalRepo()
61 ->newFile( $this->mTitle );
64 if ( !$this->mFile instanceof
File ) {
65 throw new RuntimeException(
'Expected to find file. See T250767' );
68 $this->mRepo = $this->mFile->getRepo();
69 $this->mFileLoaded =
true;
78 if ( $this->mFile->isLocal() ) {
79 return parent::followRedirect();
81 $from = $this->mFile->getRedirected();
82 $to = $this->mFile->getName();
83 if ( $from ===
null || $from === $to ) {
94 if ( $this->mFile->isLocal() ) {
95 return parent::isRedirect();
98 return $this->mFile->getRedirected() !==
null;
106 return $this->mFile->isLocal();
119 if ( $this->mDupes !==
null ) {
120 return $this->mDupes;
122 $hash = $this->mFile->getSha1();
125 return $this->mDupes;
129 $self = $this->mFile->getRepoName() .
':' . $this->mFile->getName();
130 $size = $this->mFile->getSize();
135 foreach ( $dupes as $index => $file ) {
136 $key = $file->getRepoName() .
':' . $file->getName();
137 if ( $key ===
$self || $file->getSize() != $size ) {
138 unset( $dupes[$index] );
141 $this->mDupes = $dupes;
142 return $this->mDupes;
152 if ( $this->mFile->exists() ) {
153 wfDebug(
'ImagePage::doPurge purging ' . $this->mFile->getName() );
154 $job = HTMLCacheUpdateJob::newForBacklinks(
157 [
'causeAction' =>
'file-purge' ]
161 wfDebug(
'ImagePage::doPurge no image for '
162 . $this->mFile->getName() .
"; limiting purge to cache only" );
169 $this->mFile->purgeCache( [
'forThumbRefresh' =>
true ] );
172 foreach ( $this->mFile->getHistory() as $oldFile ) {
173 $oldFile->purgeCache( [
'forThumbRefresh' =>
true ] );
176 if ( $this->mRepo ) {
178 $this->mRepo->invalidateImageRedirect( $this->mTitle );
181 return parent::doPurge();
195 $title = $this->mTitle;
196 $file = $this->mFile;
200 wfDebug( __METHOD__ .
" is not supported for this file" );
205 $repo = $file->getRepo();
206 $dbr = $repo->getReplicaDB();
207 $res = $dbr->newSelectQueryBuilder()
208 ->select( [
'page_title' =>
'lt_title',
'page_namespace' => (
string)
NS_CATEGORY ] )
210 ->join(
'categorylinks',
null,
'page_id = cl_from' )
211 ->join(
'linktarget',
null,
'cl_target_id = lt_id' )
212 ->where( [
'page_namespace' => $title->getNamespace(),
'page_title' => $title->getDBkey(), ] )
213 ->caller( __METHOD__ )
216 return $titleFactory->newTitleArrayFromResult( $res );
224 return $this->getFile()->getRepo()->getDisplayName();
232 return $this->getFile()->getDescriptionUrl();
239 $file = $this->getFile();
240 if ( $file->exists() && $file->isLocal() && !$file->getRedirected() ) {
242 return [
'delete' => FileDeleteAction::class ] + parent::getActionOverrides();
245 return parent::getActionOverrides();
250class_alias( WikiFilePage::class,
'WikiFilePage' );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Special handling for representing file pages.
doPurge()
Override handling of action=purge.
getForeignCategories()
Get the categories this file is a member of on the wiki where it was uploaded.
getActionOverrides()
Move this UI stuff somewhere elseContentHandler::getActionOverrides array
Base representation for an editable wiki page.
if(count( $args)< 1) $job