46 parent::__construct(
$title );
56 $this->mFileLoaded =
true;
63 $services = MediaWikiServices::getInstance();
64 if ( $this->mFileLoaded ) {
68 $this->mFile = $services->getRepoGroup()->findFile( $this->mTitle );
69 if ( !$this->mFile ) {
70 $this->mFile = $services->getRepoGroup()->getLocalRepo()
71 ->newFile( $this->mTitle );
74 if ( !$this->mFile instanceof
File ) {
75 throw new RuntimeException(
'Expected to find file. See T250767' );
78 $this->mRepo = $this->mFile->getRepo();
79 $this->mFileLoaded =
true;
88 if ( $this->mFile->isLocal() ) {
89 return parent::getRedirectTarget();
92 $from = $this->mFile->getRedirected();
93 $to = $this->mFile->getName();
97 $this->mRedirectTarget = Title::makeTitle(
NS_FILE, $to );
106 if ( $this->mFile->isLocal() ) {
107 return parent::followRedirect();
109 $from = $this->mFile->getRedirected();
110 $to = $this->mFile->getName();
111 if ( $from == $to ) {
114 return Title::makeTitle(
NS_FILE, $to );
122 if ( $this->mFile->isLocal() ) {
123 return parent::isRedirect();
126 return (
bool)$this->mFile->getRedirected();
134 return $this->mFile->isLocal();
150 if ( $this->mDupes !==
null ) {
151 return $this->mDupes;
153 $hash = $this->mFile->getSha1();
156 return $this->mDupes;
158 $dupes = MediaWikiServices::getInstance()->getRepoGroup()->findBySha1( $hash );
160 $self = $this->mFile->getRepoName() .
':' . $this->mFile->getName();
161 $size = $this->mFile->getSize();
166 foreach ( $dupes as $index =>
$file ) {
167 $key =
$file->getRepoName() .
':' .
$file->getName();
168 if ( $key ==
$self ) {
169 unset( $dupes[$index] );
171 if (
$file->getSize() != $size ) {
172 unset( $dupes[$index] );
175 $this->mDupes = $dupes;
176 return $this->mDupes;
186 if ( $this->mFile->exists() ) {
187 wfDebug(
'ImagePage::doPurge purging ' . $this->mFile->getName() );
191 [
'causeAction' =>
'file-purge' ]
193 MediaWikiServices::getInstance()->getJobQueueGroup()->lazyPush(
$job );
195 wfDebug(
'ImagePage::doPurge no image for '
196 . $this->mFile->getName() .
"; limiting purge to cache only" );
203 $this->mFile->purgeCache( [
'forThumbRefresh' =>
true ] );
206 foreach ( $this->mFile->getHistory() as $oldFile ) {
207 $oldFile->purgeCache( [
'forThumbRefresh' =>
true ] );
210 if ( $this->mRepo ) {
212 $this->mRepo->invalidateImageRedirect( $this->mTitle );
215 return parent::doPurge();
230 $file = $this->mFile;
233 wfDebug( __METHOD__ .
" is not supported for this file" );
238 $repo =
$file->getRepo();
239 $dbr = $repo->getReplicaDB();
242 [
'page',
'categorylinks' ],
244 'page_title' =>
'cl_to',
248 'page_namespace' =>
$title->getNamespace(),
249 'page_title' =>
$title->getDBkey(),
253 [
'categorylinks' => [
'JOIN',
'page_id = cl_from' ] ]
256 return TitleArray::newFromResult(
$res );
264 return $this->
getFile()->getRepo()->getDisplayName();
272 return $this->
getFile()->getDescriptionUrl();
280 if (
$file->exists() &&
$file->isLocal() && !
$file->getRedirected() ) {
282 return [
'delete' => FileDeleteAction::class ] + parent::getActionOverrides();
285 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.
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.