53 parent::__construct( $title );
60 $this->mFileLoaded =
true;
68 if ( $this->mFileLoaded ) {
72 $this->mFile = $services->getRepoGroup()->findFile( $this->mTitle );
73 if ( !$this->mFile ) {
74 $this->mFile = $services->getRepoGroup()->getLocalRepo()
75 ->newFile( $this->mTitle );
78 if ( !$this->mFile instanceof
File ) {
79 throw new RuntimeException(
'Expected to find file. See T250767' );
82 $this->mRepo = $this->mFile->getRepo();
83 $this->mFileLoaded =
true;
92 if ( $this->mFile->isLocal() ) {
93 return parent::followRedirect();
95 $from = $this->mFile->getRedirected();
96 $to = $this->mFile->getName();
97 if ( $from ===
null || $from === $to ) {
100 return Title::makeTitle(
NS_FILE, $to );
108 if ( $this->mFile->isLocal() ) {
109 return parent::isRedirect();
112 return $this->mFile->getRedirected() !==
null;
120 return $this->mFile->isLocal();
133 if ( $this->mDupes !==
null ) {
134 return $this->mDupes;
136 $hash = $this->mFile->getSha1();
139 return $this->mDupes;
143 $self = $this->mFile->getRepoName() .
':' . $this->mFile->getName();
144 $size = $this->mFile->getSize();
149 foreach ( $dupes as $index => $file ) {
150 $key = $file->getRepoName() .
':' . $file->getName();
151 if ( $key ===
$self || $file->getSize() != $size ) {
152 unset( $dupes[$index] );
155 $this->mDupes = $dupes;
156 return $this->mDupes;
166 if ( $this->mFile->exists() ) {
167 wfDebug(
'ImagePage::doPurge purging ' . $this->mFile->getName() );
168 $job = HTMLCacheUpdateJob::newForBacklinks(
171 [
'causeAction' =>
'file-purge' ]
175 wfDebug(
'ImagePage::doPurge no image for '
176 . $this->mFile->getName() .
"; limiting purge to cache only" );
183 $this->mFile->purgeCache( [
'forThumbRefresh' =>
true ] );
186 foreach ( $this->mFile->getHistory() as $oldFile ) {
187 $oldFile->purgeCache( [
'forThumbRefresh' =>
true ] );
190 if ( $this->mRepo ) {
192 $this->mRepo->invalidateImageRedirect( $this->mTitle );
195 return parent::doPurge();
210 $file = $this->mFile;
214 wfDebug( __METHOD__ .
" is not supported for this file" );
219 $repo = $file->getRepo();
220 $dbr = $repo->getReplicaDB();
222 $res = $dbr->newSelectQueryBuilder()
223 ->select( [
'page_title' =>
'cl_to',
'page_namespace' => (
string)
NS_CATEGORY ] )
225 ->join(
'categorylinks',
null,
'page_id = cl_from' )
226 ->where( [
'page_namespace' => $title->getNamespace(),
'page_title' => $title->getDBkey(), ] )
227 ->caller( __METHOD__ )->fetchResultSet();
229 return $titleFactory->newTitleArrayFromResult( $res );
237 return $this->
getFile()->getRepo()->getDisplayName();
245 return $this->
getFile()->getDescriptionUrl();
253 if ( $file->exists() && $file->isLocal() && !$file->getRedirected() ) {
255 return [
'delete' => FileDeleteAction::class ] + parent::getActionOverrides();
258 return parent::getActionOverrides();
263class_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.
getFile()
Get the file for this page, if one exists.
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