40 parent::__construct( $title );
47 $this->mFileLoaded =
true;
55 if ( $this->mFileLoaded ) {
59 $this->mFile = $services->getRepoGroup()->findFile( $this->mTitle );
60 if ( !$this->mFile ) {
61 $this->mFile = $services->getRepoGroup()->getLocalRepo()
62 ->newFile( $this->mTitle );
65 if ( !$this->mFile instanceof
File ) {
66 throw new RuntimeException(
'Expected to find file. See T250767' );
69 $this->mRepo = $this->mFile->getRepo();
70 $this->mFileLoaded =
true;
79 if ( $this->mFile->isLocal() ) {
80 return parent::followRedirect();
82 $from = $this->mFile->getRedirected();
83 $to = $this->mFile->getName();
84 if ( $from ===
null || $from === $to ) {
95 if ( $this->mFile->isLocal() ) {
96 return parent::isRedirect();
99 return $this->mFile->getRedirected() !==
null;
107 return $this->mFile->isLocal();
120 if ( $this->mDupes !==
null ) {
121 return $this->mDupes;
123 $hash = $this->mFile->getSha1();
126 return $this->mDupes;
130 $self = $this->mFile->getRepoName() .
':' . $this->mFile->getName();
131 $size = $this->mFile->getSize();
136 foreach ( $dupes as $index => $file ) {
137 $key = $file->getRepoName() .
':' . $file->getName();
138 if ( $key ===
$self || $file->getSize() != $size ) {
139 unset( $dupes[$index] );
142 $this->mDupes = $dupes;
143 return $this->mDupes;
153 if ( $this->mFile->exists() ) {
154 wfDebug(
'ImagePage::doPurge purging ' . $this->mFile->getName() );
155 $job = HTMLCacheUpdateJob::newForBacklinks(
158 [
'causeAction' =>
'file-purge' ]
162 wfDebug(
'ImagePage::doPurge no image for '
163 . $this->mFile->getName() .
"; limiting purge to cache only" );
170 $this->mFile->purgeCache( [
'forThumbRefresh' =>
true ] );
173 foreach ( $this->mFile->getHistory() as $oldFile ) {
174 $oldFile->purgeCache( [
'forThumbRefresh' =>
true ] );
177 if ( $this->mRepo ) {
179 $this->mRepo->invalidateImageRedirect( $this->mTitle );
182 return parent::doPurge();
196 $title = $this->mTitle;
197 $file = $this->mFile;
200 $titleFactory = $services->getTitleFactory();
201 $lbFactory = $services->getDBLoadBalancerFactory();
204 wfDebug( __METHOD__ .
" is not supported for this file" );
209 $repo = $file->getRepo();
210 $wikiId = $repo->getDbDomain();
211 $dbr = $lbFactory->getRemoteReplicaDatabase( $wikiId, LinksTable::VIRTUAL_DOMAIN );
212 $res = $dbr->newSelectQueryBuilder()
213 ->select( [
'page_title' =>
'lt_title',
'page_namespace' => (
string)
NS_CATEGORY ] )
215 ->join(
'categorylinks',
null,
'page_id = cl_from' )
216 ->join(
'linktarget',
null,
'cl_target_id = lt_id' )
217 ->where( [
'page_namespace' => $title->getNamespace(),
'page_title' => $title->getDBkey(), ] )
218 ->caller( __METHOD__ )
221 return $titleFactory->newTitleArrayFromResult( $res );
229 return $this->getFile()->getRepo()->getDisplayName();
237 return $this->getFile()->getDescriptionUrl();
244 $file = $this->getFile();
245 if ( $file->exists() && $file->isLocal() && !$file->getRedirected() ) {
247 return [
'delete' => [
248 'class' => FileDeleteAction::class,
253 ] ] + parent::getActionOverrides();
256 return parent::getActionOverrides();
261class_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.
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
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