MediaWiki  1.23.2
UploadStash.php
Go to the documentation of this file.
1 <?php
44 class UploadStash {
45 
46  // Format of the key for files -- has to be suitable as a filename itself (e.g. ab12cd34ef.jpg)
47  const KEY_FORMAT_REGEX = '/^[\w-\.]+\.\w*$/';
48 
55  public $repo;
56 
57  // array of initialized repo objects
58  protected $files = array();
59 
60  // cache of the file metadata that's stored in the database
61  protected $fileMetadata = array();
62 
63  // fileprops cache
64  protected $fileProps = array();
65 
66  // current user
67  protected $user, $userId, $isLoggedIn;
68 
77  public function __construct( FileRepo $repo, $user = null ) {
78  // this might change based on wiki's configuration.
79  $this->repo = $repo;
80 
81  // if a user was passed, use it. otherwise, attempt to use the global.
82  // this keeps FileRepo from breaking when it creates an UploadStash object
83  if ( $user ) {
84  $this->user = $user;
85  } else {
87  $this->user = $wgUser;
88  }
89 
90  if ( is_object( $this->user ) ) {
91  $this->userId = $this->user->getId();
92  $this->isLoggedIn = $this->user->isLoggedIn();
93  }
94  }
95 
108  public function getFile( $key, $noAuth = false ) {
109  if ( ! preg_match( self::KEY_FORMAT_REGEX, $key ) ) {
110  throw new UploadStashBadPathException( "key '$key' is not in a proper format" );
111  }
112 
113  if ( !$noAuth && !$this->isLoggedIn ) {
114  throw new UploadStashNotLoggedInException( __METHOD__ .
115  ' No user is logged in, files must belong to users' );
116  }
117 
118  if ( !isset( $this->fileMetadata[$key] ) ) {
119  if ( !$this->fetchFileMetadata( $key ) ) {
120  // If nothing was received, it's likely due to replication lag. Check the master to see if the record is there.
121  $this->fetchFileMetadata( $key, DB_MASTER );
122  }
123 
124  if ( !isset( $this->fileMetadata[$key] ) ) {
125  throw new UploadStashFileNotFoundException( "key '$key' not found in stash" );
126  }
127 
128  // create $this->files[$key]
129  $this->initFile( $key );
130 
131  // fetch fileprops
132  if ( strlen( $this->fileMetadata[$key]['us_props'] ) ) {
133  $this->fileProps[$key] = unserialize( $this->fileMetadata[$key]['us_props'] );
134  } else { // b/c for rows with no us_props
135  wfDebug( __METHOD__ . " fetched props for $key from file\n" );
136  $path = $this->fileMetadata[$key]['us_path'];
137  $this->fileProps[$key] = $this->repo->getFileProps( $path );
138  }
139  }
140 
141  if ( ! $this->files[$key]->exists() ) {
142  wfDebug( __METHOD__ . " tried to get file at $key, but it doesn't exist\n" );
143  throw new UploadStashBadPathException( "path doesn't exist" );
144  }
145 
146  if ( !$noAuth ) {
147  if ( $this->fileMetadata[$key]['us_user'] != $this->userId ) {
148  throw new UploadStashWrongOwnerException( "This file ($key) doesn't belong to the current user." );
149  }
150  }
151 
152  return $this->files[$key];
153  }
154 
161  public function getMetadata( $key ) {
162  $this->getFile( $key );
163  return $this->fileMetadata[$key];
164  }
165 
172  public function getFileProps( $key ) {
173  $this->getFile( $key );
174  return $this->fileProps[$key];
175  }
176 
187  public function stashFile( $path, $sourceType = null ) {
188  if ( !is_file( $path ) ) {
189  wfDebug( __METHOD__ . " tried to stash file at '$path', but it doesn't exist\n" );
190  throw new UploadStashBadPathException( "path doesn't exist" );
191  }
193  wfDebug( __METHOD__ . " stashing file at '$path'\n" );
194 
195  // we will be initializing from some tmpnam files that don't have extensions.
196  // most of MediaWiki assumes all uploaded files have good extensions. So, we fix this.
197  $extension = self::getExtensionForPath( $path );
198  if ( !preg_match( "/\\.\\Q$extension\\E$/", $path ) ) {
199  $pathWithGoodExtension = "$path.$extension";
200  } else {
201  $pathWithGoodExtension = $path;
202  }
203 
204  // If no key was supplied, make one. a mysql insertid would be totally reasonable here, except
205  // that for historical reasons, the key is this random thing instead. At least it's not guessable.
206  //
207  // some things that when combined will make a suitably unique key.
208  // see: http://www.jwz.org/doc/mid.html
209  list( $usec, $sec ) = explode( ' ', microtime() );
210  $usec = substr( $usec, 2 );
211  $key = wfBaseConvert( $sec . $usec, 10, 36 ) . '.' .
212  wfBaseConvert( mt_rand(), 10, 36 ) . '.' .
213  $this->userId . '.' .
214  $extension;
215 
216  $this->fileProps[$key] = $fileProps;
217 
218  if ( ! preg_match( self::KEY_FORMAT_REGEX, $key ) ) {
219  throw new UploadStashBadPathException( "key '$key' is not in a proper format" );
220  }
221 
222  wfDebug( __METHOD__ . " key for '$path': $key\n" );
223 
224  // if not already in a temporary area, put it there
225  $storeStatus = $this->repo->storeTemp( basename( $pathWithGoodExtension ), $path );
226 
227  if ( ! $storeStatus->isOK() ) {
228  // It is a convention in MediaWiki to only return one error per API exception, even if multiple errors
229  // are available. We use reset() to pick the "first" thing that was wrong, preferring errors to warnings.
230  // This is a bit lame, as we may have more info in the $storeStatus and we're throwing it away, but to fix it means
231  // redesigning API errors significantly.
232  // $storeStatus->value just contains the virtual URL (if anything) which is probably useless to the caller
233  $error = $storeStatus->getErrorsArray();
234  $error = reset( $error );
235  if ( ! count( $error ) ) {
236  $error = $storeStatus->getWarningsArray();
237  $error = reset( $error );
238  if ( ! count( $error ) ) {
239  $error = array( 'unknown', 'no error recorded' );
240  }
241  }
242  // at this point, $error should contain the single "most important" error, plus any parameters.
243  $errorMsg = array_shift( $error );
244  throw new UploadStashFileException( "Error storing file in '$path': " . wfMessage( $errorMsg, $error )->text() );
245  }
246  $stashPath = $storeStatus->value;
247 
248  // fetch the current user ID
249  if ( !$this->isLoggedIn ) {
250  throw new UploadStashNotLoggedInException( __METHOD__ . ' No user is logged in, files must belong to users' );
251  }
252 
253  // insert the file metadata into the db.
254  wfDebug( __METHOD__ . " inserting $stashPath under $key\n" );
255  $dbw = $this->repo->getMasterDb();
256 
257  $this->fileMetadata[$key] = array(
258  'us_id' => $dbw->nextSequenceValue( 'uploadstash_us_id_seq' ),
259  'us_user' => $this->userId,
260  'us_key' => $key,
261  'us_orig_path' => $path,
262  'us_path' => $stashPath, // virtual URL
263  'us_props' => $dbw->encodeBlob( serialize( $fileProps ) ),
264  'us_size' => $fileProps['size'],
265  'us_sha1' => $fileProps['sha1'],
266  'us_mime' => $fileProps['mime'],
267  'us_media_type' => $fileProps['media_type'],
268  'us_image_width' => $fileProps['width'],
269  'us_image_height' => $fileProps['height'],
270  'us_image_bits' => $fileProps['bits'],
271  'us_source_type' => $sourceType,
272  'us_timestamp' => $dbw->timestamp(),
273  'us_status' => 'finished'
274  );
275 
276  $dbw->insert(
277  'uploadstash',
278  $this->fileMetadata[$key],
279  __METHOD__
280  );
281 
282  // store the insertid in the class variable so immediate retrieval (possibly laggy) isn't necesary.
283  $this->fileMetadata[$key]['us_id'] = $dbw->insertId();
284 
285  # create the UploadStashFile object for this file.
286  $this->initFile( $key );
287 
288  return $this->getFile( $key );
289  }
290 
298  public function clear() {
299  if ( !$this->isLoggedIn ) {
300  throw new UploadStashNotLoggedInException( __METHOD__ . ' No user is logged in, files must belong to users' );
301  }
302 
303  wfDebug( __METHOD__ . ' clearing all rows for user ' . $this->userId . "\n" );
304  $dbw = $this->repo->getMasterDb();
305  $dbw->delete(
306  'uploadstash',
307  array( 'us_user' => $this->userId ),
308  __METHOD__
309  );
310 
311  # destroy objects.
312  $this->files = array();
313  $this->fileMetadata = array();
314 
315  return true;
316  }
317 
325  public function removeFile( $key ) {
326  if ( !$this->isLoggedIn ) {
327  throw new UploadStashNotLoggedInException( __METHOD__ . ' No user is logged in, files must belong to users' );
328  }
329 
330  $dbw = $this->repo->getMasterDb();
331 
332  // this is a cheap query. it runs on the master so that this function still works when there's lag.
333  // it won't be called all that often.
334  $row = $dbw->selectRow(
335  'uploadstash',
336  'us_user',
337  array( 'us_key' => $key ),
338  __METHOD__
339  );
340 
341  if ( !$row ) {
342  throw new UploadStashNoSuchKeyException( "No such key ($key), cannot remove" );
343  }
344 
345  if ( $row->us_user != $this->userId ) {
346  throw new UploadStashWrongOwnerException( "Can't delete: the file ($key) doesn't belong to this user." );
347  }
348 
349  return $this->removeFileNoAuth( $key );
350  }
351 
358  public function removeFileNoAuth( $key ) {
359  wfDebug( __METHOD__ . " clearing row $key\n" );
360 
361  // Ensure we have the UploadStashFile loaded for this key
362  $this->getFile( $key, true );
363 
364  $dbw = $this->repo->getMasterDb();
365 
366  $dbw->delete(
367  'uploadstash',
368  array( 'us_key' => $key ),
369  __METHOD__
370  );
371 
372  // TODO: look into UnregisteredLocalFile and find out why the rv here is sometimes wrong (false when file was removed)
373  // for now, ignore.
374  $this->files[$key]->remove();
375 
376  unset( $this->files[$key] );
377  unset( $this->fileMetadata[$key] );
378 
379  return true;
380  }
381 
388  public function listFiles() {
389  if ( !$this->isLoggedIn ) {
390  throw new UploadStashNotLoggedInException( __METHOD__ . ' No user is logged in, files must belong to users' );
391  }
392 
393  $dbr = $this->repo->getSlaveDb();
394  $res = $dbr->select(
395  'uploadstash',
396  'us_key',
397  array( 'us_user' => $this->userId ),
398  __METHOD__
399  );
400 
401  if ( !is_object( $res ) || $res->numRows() == 0 ) {
402  // nothing to do.
403  return false;
404  }
405 
406  // finish the read before starting writes.
407  $keys = array();
408  foreach ( $res as $row ) {
409  array_push( $keys, $row->us_key );
410  }
411 
412  return $keys;
413  }
414 
425  public static function getExtensionForPath( $path ) {
426  global $wgFileBlacklist;
427  // Does this have an extension?
428  $n = strrpos( $path, '.' );
429  $extension = null;
430  if ( $n !== false ) {
431  $extension = $n ? substr( $path, $n + 1 ) : '';
432  } else {
433  // If not, assume that it should be related to the mime type of the original file.
434  $magic = MimeMagic::singleton();
435  $mimeType = $magic->guessMimeType( $path );
436  $extensions = explode( ' ', MimeMagic::singleton()->getExtensionsForType( $mimeType ) );
437  if ( count( $extensions ) ) {
438  $extension = $extensions[0];
439  }
440  }
441 
442  if ( is_null( $extension ) ) {
443  throw new UploadStashFileException( "extension is null" );
444  }
445 
446  $extension = File::normalizeExtension( $extension );
447  if ( in_array( $extension, $wgFileBlacklist ) ) {
448  // The file should already be checked for being evil.
449  // However, if somehow we got here, we definitely
450  // don't want to give it an extension of .php and
451  // put it in a web accesible directory.
452  return '';
453  }
454  return $extension;
455  }
456 
464  protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) {
465  // populate $fileMetadata[$key]
466  $dbr = null;
467  if ( $readFromDB === DB_MASTER ) {
468  // sometimes reading from the master is necessary, if there's replication lag.
469  $dbr = $this->repo->getMasterDb();
470  } else {
471  $dbr = $this->repo->getSlaveDb();
472  }
473 
474  $row = $dbr->selectRow(
475  'uploadstash',
476  '*',
477  array( 'us_key' => $key ),
478  __METHOD__
479  );
480 
481  if ( !is_object( $row ) ) {
482  // key wasn't present in the database. this will happen sometimes.
483  return false;
484  }
485 
486  $this->fileMetadata[$key] = (array)$row;
487  $this->fileMetadata[$key]['us_props'] = $dbr->decodeBlob( $row->us_props );
488 
489  return true;
490  }
491 
499  protected function initFile( $key ) {
500  $file = new UploadStashFile( $this->repo, $this->fileMetadata[$key]['us_path'], $key );
501  if ( $file->getSize() === 0 ) {
502  throw new UploadStashZeroLengthFileException( "File is zero length" );
503  }
504  $this->files[$key] = $file;
505  return true;
506  }
507 }
508 
510  private $fileKey;
511  private $urlName;
512  protected $url;
513 
524  public function __construct( $repo, $path, $key ) {
525  $this->fileKey = $key;
526 
527  // resolve mwrepo:// urls
528  if ( $repo->isVirtualUrl( $path ) ) {
530  } else {
531 
532  // check if path appears to be sane, no parent traversals, and is in this repo's temp zone.
533  $repoTempPath = $repo->getZonePath( 'temp' );
534  if ( ( ! $repo->validateFilename( $path ) ) ||
535  ( strpos( $path, $repoTempPath ) !== 0 ) ) {
536  wfDebug( "UploadStash: tried to construct an UploadStashFile from a file that should already exist at '$path', but path is not valid\n" );
537  throw new UploadStashBadPathException( 'path is not valid' );
538  }
539 
540  // check if path exists! and is a plain file.
541  if ( ! $repo->fileExists( $path ) ) {
542  wfDebug( "UploadStash: tried to construct an UploadStashFile from a file that should already exist at '$path', but path is not found\n" );
543  throw new UploadStashFileNotFoundException( 'cannot find path, or not a plain file' );
544  }
545  }
546 
547  parent::__construct( false, $repo, $path, false );
548 
549  $this->name = basename( $this->path );
550  }
551 
560  public function getDescriptionUrl() {
561  return $this->getUrl();
562  }
563 
572  public function getThumbPath( $thumbName = false ) {
573  $path = dirname( $this->path );
574  if ( $thumbName !== false ) {
575  $path .= "/$thumbName";
576  }
577  return $path;
578  }
579 
589  function thumbName( $params, $flags = 0 ) {
590  return $this->generateThumbName( $this->getUrlName(), $params );
591  }
592 
598  private function getSpecialUrl( $subPage ) {
599  return SpecialPage::getTitleFor( 'UploadStash', $subPage )->getLocalURL();
600  }
601 
611  public function getThumbUrl( $thumbName = false ) {
612  wfDebug( __METHOD__ . " getting for $thumbName \n" );
613  return $this->getSpecialUrl( 'thumb/' . $this->getUrlName() . '/' . $thumbName );
614  }
615 
622  public function getUrlName() {
623  if ( ! $this->urlName ) {
624  $this->urlName = $this->fileKey;
625  }
626  return $this->urlName;
627  }
628 
635  public function getUrl() {
636  if ( !isset( $this->url ) ) {
637  $this->url = $this->getSpecialUrl( 'file/' . $this->getUrlName() );
638  }
639  return $this->url;
640  }
641 
648  public function getFullUrl() {
649  return $this->getUrl();
650  }
651 
657  public function getFileKey() {
658  return $this->fileKey;
659  }
660 
665  public function remove() {
666  if ( !$this->repo->fileExists( $this->path ) ) {
667  // Maybe the file's already been removed? This could totally happen in UploadBase.
668  return true;
669  }
670 
671  return $this->repo->freeTemp( $this->path );
672  }
673 
674  public function exists() {
675  return $this->repo->fileExists( $this->path );
676  }
677 
678 }
679 
UploadStash\removeFileNoAuth
removeFileNoAuth( $key)
Remove a file (see removeFile), but doesn't check ownership first.
Definition: UploadStash.php:357
$wgUser
$wgUser
Definition: Setup.php:552
File\$repo
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
Definition: File.php:94
UploadStashFile\getUrlName
getUrlName()
The basename for the URL, which we want to not be related to the filename.
Definition: UploadStash.php:621
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
UploadStash\$userId
$userId
Definition: UploadStash.php:66
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
UploadStash\$fileProps
$fileProps
Definition: UploadStash.php:63
UploadStashNotLoggedInException
Definition: UploadStash.php:685
UploadStashBadPathException
Definition: UploadStash.php:682
FileRepo\validateFilename
validateFilename( $filename)
Determine if a relative path is valid, i.e.
Definition: FileRepo.php:1627
UploadStash\KEY_FORMAT_REGEX
const KEY_FORMAT_REGEX
Definition: UploadStash.php:47
$extensions
$extensions
Definition: importImages.php:62
FSFile\getPropsFromPath
static getPropsFromPath( $path, $ext=true)
Get an associative array containing information about a file in the local filesystem.
Definition: FSFile.php:243
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
UploadStash\listFiles
listFiles()
List all files in the stash.
Definition: UploadStash.php:387
UploadStashWrongOwnerException
Definition: UploadStash.php:686
UnregisteredLocalFile
A file object referring to either a standalone local file, or a file in a local repository with no da...
Definition: UnregisteredLocalFile.php:36
UploadStash
UploadStash is intended to accomplish a few things:
Definition: UploadStash.php:44
UploadStash\getExtensionForPath
static getExtensionForPath( $path)
Find or guess extension – ensuring that our extension matches our mime type.
Definition: UploadStash.php:424
$n
$n
Definition: RandomTest.php:76
UploadStash\$fileMetadata
$fileMetadata
Definition: UploadStash.php:60
UploadStash\getFile
getFile( $key, $noAuth=false)
Get a file and its metadata from the stash.
Definition: UploadStash.php:107
UploadStash\getMetadata
getMetadata( $key)
Getter for file metadata.
Definition: UploadStash.php:160
UploadStash\stashFile
stashFile( $path, $sourceType=null)
Stash a file in a temp directory and record that we did this in the database, along with other metada...
Definition: UploadStash.php:186
$params
$params
Definition: styleTest.css.php:40
UploadStashFile
Definition: UploadStash.php:508
FileRepo\getZonePath
getZonePath( $zone)
Get the storage path corresponding to one of the zones.
Definition: FileRepo.php:355
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
UploadStash\$files
$files
Definition: UploadStash.php:57
UploadStashFileException
Definition: UploadStash.php:683
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2113
UnregisteredLocalFile\$path
string $path
Definition: UnregisteredLocalFile.php:39
$dbr
$dbr
Definition: testCompression.php:48
FileRepo
Base class for file repositories.
Definition: FileRepo.php:37
File\normalizeExtension
static normalizeExtension( $ext)
Normalize a file extension to the common form, and ensure it's clean.
Definition: File.php:200
MWException
MediaWiki exception.
Definition: MWException.php:26
UploadStash\getFileProps
getFileProps( $key)
Getter for fileProps.
Definition: UploadStash.php:171
UploadStashNotAvailableException
Definition: UploadStash.php:680
UploadStashFile\getThumbPath
getThumbPath( $thumbName=false)
Get the path for the thumbnail (actually any transformation of this file) The actual argument is the ...
Definition: UploadStash.php:571
UploadStashFile\$urlName
$urlName
Definition: UploadStash.php:510
UploadStashZeroLengthFileException
Definition: UploadStash.php:684
UploadStash\__construct
__construct(FileRepo $repo, $user=null)
Represents a temporary filestore, with metadata in the database.
Definition: UploadStash.php:76
wfMessage
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
UploadStashFile\getFullUrl
getFullUrl()
Parent classes use this method, for no obvious reason, to return the path (relative to wiki root,...
Definition: UploadStash.php:647
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
FileRepo\fileExists
fileExists( $file)
Checks existence of a a file.
Definition: FileRepo.php:1340
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
UploadStashNoSuchKeyException
Definition: UploadStash.php:687
UploadStash\removeFile
removeFile( $key)
Remove a particular file from the stash.
Definition: UploadStash.php:324
UploadStashFile\$fileKey
$fileKey
Definition: UploadStash.php:509
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:933
UploadStashFile\$url
$url
Definition: UploadStash.php:511
user
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
UploadStash\$user
$user
Definition: UploadStash.php:66
File\generateThumbName
generateThumbName( $name, $params)
Generate a thumbnail file name from a name and specified parameters.
Definition: File.php:855
UploadStashFile\thumbName
thumbName( $params, $flags=0)
Return the file/url base name of a thumbnail with the specified parameters.
Definition: UploadStash.php:588
UploadStashFileNotFoundException
Definition: UploadStash.php:681
UploadStashFile\getDescriptionUrl
getDescriptionUrl()
A method needed by the file transforming and scaling routines in File.php We do not necessarily care ...
Definition: UploadStash.php:559
UploadStash\initFile
initFile( $key)
Helper function: Initialize the UploadStashFile for a given file.
Definition: UploadStash.php:498
UploadStash\$isLoggedIn
$isLoggedIn
Definition: UploadStash.php:66
UploadStashFile\getSpecialUrl
getSpecialUrl( $subPage)
Helper function – given a 'subpage', return the local URL e.g.
Definition: UploadStash.php:597
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
UploadStashFile\getFileKey
getFileKey()
Getter for file key (the unique id by which this file's location & metadata is stored in the db)
Definition: UploadStash.php:656
UploadStashFile\__construct
__construct( $repo, $path, $key)
A LocalFile wrapper around a file that has been temporarily stashed, so we can do things like create ...
Definition: UploadStash.php:523
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
UploadStashFile\exists
exists()
Returns true if file exists in the repository.
Definition: UploadStash.php:673
wfBaseConvert
wfBaseConvert( $input, $sourceBase, $destBase, $pad=1, $lowercase=true, $engine='auto')
Convert an arbitrarily-long digit string from one numeric base to another, optionally zero-padding to...
Definition: GlobalFunctions.php:3368
UploadStashFile\getUrl
getUrl()
Return the URL of the file, if for some reason we wanted to download it We tend not to do this for th...
Definition: UploadStash.php:634
$path
$path
Definition: NoLocalSettings.php:35
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
FileRepo\isVirtualUrl
static isVirtualUrl( $url)
Determine if a string is an mwrepo:// URL.
Definition: FileRepo.php:229
FileRepo\resolveVirtualUrl
resolveVirtualUrl( $url)
Get the backend storage path corresponding to a virtual URL.
Definition: FileRepo.php:315
$keys
$keys
Definition: testCompression.php:63
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
$error
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
Definition: hooks.txt:2573
UploadStash\clear
clear()
Remove all files from the stash.
Definition: UploadStash.php:297
$res
$res
Definition: database.txt:21
UploadStash\$repo
LocalRepo $repo
repository that this uses to store temp files public because we sometimes need to get a LocalFile wit...
Definition: UploadStash.php:54
LocalRepo
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition: LocalRepo.php:31
UploadStashException
Definition: UploadStash.php:679
UploadStashFile\getThumbUrl
getThumbUrl( $thumbName=false)
Get a URL to access the thumbnail This is required because the model of how files work requires that ...
Definition: UploadStash.php:610
UploadStash\fetchFileMetadata
fetchFileMetadata( $key, $readFromDB=DB_SLAVE)
Helper function: do the actual database query to fetch file metadata.
Definition: UploadStash.php:463