MediaWiki REL1_30
ForeignDBFile.php
Go to the documentation of this file.
1<?php
25
31class ForeignDBFile extends LocalFile {
38 static function newFromTitle( $title, $repo, $unused = null ) {
39 return new self( $title, $repo );
40 }
41
50 static function newFromRow( $row, $repo ) {
51 $title = Title::makeTitle( NS_FILE, $row->img_name );
52 $file = new self( $title, $repo );
53 $file->loadFromRow( $row );
54
55 return $file;
56 }
57
65 function publish( $srcPath, $flags = 0, array $options = [] ) {
66 $this->readOnlyError();
67 }
68
81 function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '',
82 $watch = false, $timestamp = false, User $user = null ) {
83 $this->readOnlyError();
84 }
85
92 function restore( $versions = [], $unsuppress = false ) {
93 $this->readOnlyError();
94 }
95
103 function delete( $reason, $suppress = false, $user = null ) {
104 $this->readOnlyError();
105 }
106
112 function move( $target ) {
113 $this->readOnlyError();
114 }
115
119 function getDescriptionUrl() {
120 // Restore remote behavior
122 }
123
128 function getDescriptionText( $lang = null ) {
129 global $wgLang;
130
131 if ( !$this->repo->fetchDescription ) {
132 return false;
133 }
134
135 $lang = $lang ?: $wgLang;
136 $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
137 if ( !$renderUrl ) {
138 return false;
139 }
140
141 $touched = $this->repo->getReplicaDB()->selectField(
142 'page',
143 'page_touched',
144 [
145 'page_namespace' => NS_FILE,
146 'page_title' => $this->title->getDBkey()
147 ]
148 );
149 if ( $touched === false ) {
150 return false; // no description page
151 }
152
153 $cache = ObjectCache::getMainWANInstance();
154
155 return $cache->getWithSetCallback(
156 $this->repo->getLocalCacheKey(
157 'RemoteFileDescription',
158 'url',
159 $lang->getCode(),
160 $this->getName(),
161 $touched
162 ),
163 $this->repo->descriptionCacheExpiry ?: $cache::TTL_UNCACHEABLE,
164 function ( $oldValue, &$ttl, array &$setOpts ) use ( $renderUrl ) {
165 wfDebug( "Fetching shared description from $renderUrl\n" );
166 $res = Http::get( $renderUrl, [], __METHOD__ );
167 if ( !$res ) {
168 $ttl = WANObjectCache::TTL_UNCACHEABLE;
169 }
170
171 return $res;
172 }
173 );
174 }
175
183 public function getDescriptionShortUrl() {
184 $dbr = $this->repo->getReplicaDB();
185 $pageId = $dbr->selectField(
186 'page',
187 'page_id',
188 [
189 'page_namespace' => NS_FILE,
190 'page_title' => $this->title->getDBkey()
191 ]
192 );
193
194 if ( $pageId !== false ) {
195 $url = $this->repo->makeUrl( [ 'curid' => $pageId ] );
196 if ( $url !== false ) {
197 return $url;
198 }
199 }
200 return null;
201 }
202
203}
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
string $url
The URL corresponding to one of the four basic zones.
Definition File.php:117
getName()
Return the name of this file.
Definition File.php:297
readOnlyError()
Definition File.php:1768
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
Definition File.php:96
Title string bool $title
Definition File.php:99
getDescriptionUrl()
Get the URL of the image description page.
Definition File.php:2022
Foreign file with an accessible MediaWiki database.
getDescriptionText( $lang=null)
publish( $srcPath, $flags=0, array $options=[])
static newFromRow( $row, $repo)
Create a ForeignDBFile from a title Do not call this except from inside a repo class.
getDescriptionShortUrl()
Get short description URL for a file based on the page ID.
restore( $versions=[], $unsuppress=false)
recordUpload( $oldver, $desc, $license='', $copyStatus='', $source='', $watch=false, $timestamp=false, User $user=null)
static newFromTitle( $title, $repo, $unused=null)
Class to represent a local file in the wiki's own database.
Definition LocalFile.php:45
string $timestamp
Upload timestamp.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:51
if(! $regexes) $dbr
Definition cleanup.php:94
$res
Definition database.txt:21
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition design.txt:56
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1971
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition hooks.txt:2805
const NS_FILE
Definition Defines.php:71
$cache
Definition mcc.php:33
$source
if(!isset( $args[0])) $lang