Go to the documentation of this file.
164 $file->loadFromRow( $row );
181 $conds = [
'img_sha1' =>
$sha1 ];
186 $row =
$dbr->selectRow(
'image', self::selectFields(), $conds, __METHOD__ );
226 $this->metadata =
'';
227 $this->historyLine = 0;
228 $this->historyRes =
null;
229 $this->dataLoaded =
false;
230 $this->extraDataLoaded =
false;
242 return $this->repo->getSharedCacheKey(
'file', sha1( $this->
getName() ) );
258 $this->dataLoaded =
false;
259 $this->extraDataLoaded =
false;
269 $cachedValues =
$cache->getWithSetCallback(
273 $setOpts += Database::getCacheSetOptions( $this->repo->getReplicaDB() );
279 if ( $this->fileExists ) {
280 foreach ( $fields
as $field ) {
281 $cacheVal[$field] = $this->$field;
288 if ( isset( $cacheVal[$field] )
289 && strlen( $cacheVal[$field] ) > 100 * 1024
291 unset( $cacheVal[$field] );
295 if ( $this->fileExists ) {
298 $ttl = $cache::TTL_DAY;
306 $this->fileExists = $cachedValues[
'fileExists'];
307 if ( $this->fileExists ) {
311 $this->dataLoaded =
true;
312 $this->extraDataLoaded =
true;
314 $this->extraDataLoaded = $this->extraDataLoaded && isset( $cachedValues[$field] );
327 $this->repo->getMasterDB()->onTransactionPreCommitOrIdle(
328 function ()
use ( $key ) {
339 $props = $this->repo->getFileProps( $this->
getVirtualUrl() );
348 static $fields = [
'size',
'width',
'height',
'bits',
'media_type',
349 'major_mime',
'minor_mime',
'metadata',
'timestamp',
'sha1',
'user',
351 static $results = [];
353 if ( $prefix ==
'' ) {
354 return array_merge( $fields, [
'description' ] );
356 if ( !isset( $results[$prefix] ) ) {
357 $prefixedFields = [];
358 foreach ( $fields
as $field ) {
359 $prefixedFields[] = $prefix . $field;
362 $results[$prefix] = $prefixedFields;
365 return $results[$prefix];
373 static $fields = [
'metadata' ];
374 static $results = [];
376 if ( $prefix ==
'' ) {
380 if ( !isset( $results[$prefix] ) ) {
381 $prefixedFields = [];
382 foreach ( $fields
as $field ) {
383 $prefixedFields[] = $prefix . $field;
385 $results[$prefix] = $prefixedFields;
388 return $results[$prefix];
398 # Unconditionally set loaded=true, we don't want the accessors constantly rechecking
399 $this->dataLoaded =
true;
400 $this->extraDataLoaded =
true;
403 ? $this->repo->getMasterDB()
404 : $this->repo->getReplicaDB();
412 $this->fileExists =
false;
423 # Unconditionally set loaded=true, we don't want the accessors constantly rechecking
424 $this->extraDataLoaded =
true;
436 throw new MWException(
"Could not find data for image '{$this->getName()}'." );
449 'img_name' => $this->
getName(),
450 'img_timestamp' =>
$dbr->timestamp( $this->getTimestamp() )
455 # File may have been uploaded over in the meantime; check the old versions
458 'oi_timestamp' =>
$dbr->timestamp( $this->getTimestamp() )
475 $array = (
array)$row;
476 $prefixLength = strlen( $prefix );
479 if ( substr(
key( $array ), 0, $prefixLength ) !== $prefix ) {
480 throw new MWException( __METHOD__ .
': incorrect $prefix parameter' );
502 $decoded[
'timestamp'] =
wfTimestamp( TS_MW, $decoded[
'timestamp'] );
504 $decoded[
'metadata'] = $this->repo->getReplicaDB()->decodeBlob( $decoded[
'metadata'] );
506 if ( empty( $decoded[
'major_mime'] ) ) {
507 $decoded[
'mime'] =
'unknown/unknown';
509 if ( !$decoded[
'minor_mime'] ) {
510 $decoded[
'minor_mime'] =
'unknown';
512 $decoded[
'mime'] = $decoded[
'major_mime'] .
'/' . $decoded[
'minor_mime'];
516 $decoded[
'sha1'] = rtrim( $decoded[
'sha1'],
"\0" );
522 foreach ( [
'size',
'width',
'height',
'bits' ]
as $field ) {
523 $decoded[$field] = +$decoded[$field];
536 $this->dataLoaded =
true;
537 $this->extraDataLoaded =
true;
543 $array = $this->
decodeRow( $row, $prefix );
549 $this->fileExists =
true;
558 if ( !$this->dataLoaded ) {
559 if (
$flags & self::READ_LATEST ) {
566 if ( (
$flags & self::LOAD_ALL ) && !$this->extraDataLoaded ) {
583 if ( is_null( $this->media_type ) || $this->mime ==
'image/svg' ) {
598 $this->upgrading =
true;
601 $this->upgrading =
false;
626 # Don't destroy file info of missing files
627 if ( !$this->fileExists ) {
629 wfDebug( __METHOD__ .
": file does not exist, aborting\n" );
634 $dbw = $this->repo->getMasterDB();
642 wfDebug( __METHOD__ .
': upgrading ' . $this->
getName() .
" to the current schema\n" );
644 $dbw->update(
'image',
646 'img_size' => $this->size,
647 'img_width' => $this->
width,
648 'img_height' => $this->height,
649 'img_bits' => $this->bits,
650 'img_media_type' => $this->media_type,
651 'img_major_mime' => $major,
652 'img_minor_mime' => $minor,
653 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
656 [
'img_name' => $this->
getName() ],
663 $this->upgraded =
true;
677 $this->dataLoaded =
true;
679 $fields[] =
'fileExists';
681 foreach ( $fields
as $field ) {
682 if ( isset( $info[$field] ) ) {
683 $this->$field = $info[$field];
688 if ( isset( $info[
'major_mime'] ) ) {
689 $this->mime =
"{$info['major_mime']}/{$info['minor_mime']}";
690 } elseif ( isset( $info[
'mime'] ) ) {
691 $this->mime = $info[
'mime'];
708 if ( $this->missing ===
null ) {
737 return $dim[
'width'];
769 return $dim[
'height'];
789 if (
$type ==
'text' ) {
804 $pageId = $this->
title->getArticleID();
806 if ( $pageId !==
null ) {
807 $url = $this->repo->makeUrl( [
'curid' => $pageId ] );
808 if (
$url !==
false ) {
820 $this->
load( self::LOAD_ALL );
896 if ( $archiveName ) {
902 $backend = $this->repo->getBackend();
905 $iterator = $backend->getFileList( [
'dir' =>
$dir ] );
906 foreach ( $iterator
as $file ) {
952 Hooks::run(
'LocalFilePurgeThumbnails', [ $this, $archiveName ] );
955 $dir = array_shift( $files );
960 foreach ( $files
as $file ) {
974 foreach ( $files
as $file ) {
977 array_shift( $urls );
980 if ( !empty(
$options[
'forThumbRefresh'] ) ) {
988 Hooks::run(
'LocalFilePurgeThumbnails', [ $this,
false ] );
991 $dir = array_shift( $files );
1015 [
'transformParams' => [
'width' => $size ] ]
1031 $fileListDebug = strtr(
1032 var_export( $files,
true ),
1035 wfDebug( __METHOD__ .
": $fileListDebug\n" );
1038 foreach ( $files
as $file ) {
1039 if ( $this->repo->supportsSha1URLs() ) {
1040 $reference = $this->
getSha1();
1042 $reference = $this->
getName();
1045 # Check that the reference (filename or sha1) is part of the thumb name
1046 # This is a basic sanity check to avoid erasing unrelated directories
1047 if ( strpos( $file, $reference ) !==
false
1048 || strpos( $file,
"-thumbnail" ) !==
false
1050 $purgeList[] =
"{$dir}/{$file}";
1054 # Delete the thumbnails
1055 $this->repo->quickPurgeBatch( $purgeList );
1056 # Clear out the thumbnail directory if empty
1057 $this->repo->quickCleanDir(
$dir );
1070 function getHistory( $limit =
null, $start =
null, $end =
null, $inc =
true ) {
1071 $dbr = $this->repo->getReplicaDB();
1074 $conds = $opts = $join_conds = [];
1075 $eq = $inc ?
'=' :
'';
1076 $conds[] =
"oi_name = " .
$dbr->addQuotes( $this->
title->getDBkey() );
1079 $conds[] =
"oi_timestamp <$eq " .
$dbr->addQuotes(
$dbr->timestamp( $start ) );
1083 $conds[] =
"oi_timestamp >$eq " .
$dbr->addQuotes(
$dbr->timestamp( $end ) );
1087 $opts[
'LIMIT'] = $limit;
1091 $order = ( !$start && $end !== null ) ?
'ASC' :
'DESC';
1092 $opts[
'ORDER BY'] =
"oi_timestamp $order";
1093 $opts[
'USE INDEX'] = [
'oldimage' =>
'oi_name_timestamp' ];
1098 &$conds, &$opts, &$join_conds ] );
1100 $res =
$dbr->select(
$tables, $fields, $conds, __METHOD__, $opts, $join_conds );
1103 foreach (
$res as $row ) {
1104 $r[] = $this->repo->newFileFromRow( $row );
1107 if ( $order ==
'ASC' ) {
1108 $r = array_reverse( $r );
1124 # Polymorphic function name to distinguish foreign and local fetches
1127 $dbr = $this->repo->getReplicaDB();
1129 if ( $this->historyLine == 0 ) {
1130 $this->historyRes =
$dbr->select(
'image',
1131 self::selectFields() + [
1132 'oi_archive_name' =>
$dbr->addQuotes(
'' ),
1135 [
'img_name' => $this->
title->getDBkey() ],
1139 if ( 0 ==
$dbr->numRows( $this->historyRes ) ) {
1140 $this->historyRes =
null;
1144 } elseif ( $this->historyLine == 1 ) {
1145 $this->historyRes =
$dbr->select(
1148 [
'oi_name' => $this->
title->getDBkey() ],
1150 [
'ORDER BY' =>
'oi_timestamp DESC' ]
1153 $this->historyLine++;
1155 return $dbr->fetchObject( $this->historyRes );
1162 $this->historyLine = 0;
1164 if ( !is_null( $this->historyRes ) ) {
1165 $this->historyRes =
null;
1202 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1206 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
1208 if ( $this->repo->isVirtualUrl( $srcPath )
1211 $props = $this->repo->getFileProps( $srcPath );
1214 $props = $mwProps->getPropsFromPath( $srcPath,
true );
1221 $metadata = MediaWiki\quietCall(
'unserialize', $props[
'metadata'] );
1233 $comment = trim( $comment );
1238 if (
$status->successCount >= 2 ) {
1247 $status->fatal(
'filenotfound', $srcPath );
1300 $oldver, $comment, $pageText, $props =
false,
$timestamp =
false,
$user =
null, $tags = []
1304 if ( is_null(
$user ) ) {
1309 $dbw = $this->repo->getMasterDB();
1311 # Imports or such might force a certain timestamp; otherwise we generate
1312 # it and can fudge it slightly to keep (name,timestamp) unique on re-upload.
1315 $allowTimeKludge =
true;
1317 $allowTimeKludge =
false;
1320 $props = $props ?: $this->repo->getFileProps( $this->
getVirtualUrl() );
1321 $props[
'description'] = $comment;
1322 $props[
'user'] =
$user->getId();
1323 $props[
'user_text'] =
$user->getName();
1327 # Fail now if the file isn't there
1328 if ( !$this->fileExists ) {
1329 wfDebug( __METHOD__ .
": File " . $this->
getRel() .
" went missing!\n" );
1334 $dbw->startAtomic( __METHOD__ );
1336 # Test to see if the row exists using INSERT IGNORE
1337 # This avoids race conditions by locking the row until the commit, and also
1338 # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
1340 list( $commentFields, $commentCallback ) =
1341 $commentStore->insertWithTempTable( $dbw, $comment );
1342 $dbw->insert(
'image',
1344 'img_name' => $this->
getName(),
1345 'img_size' => $this->size,
1346 'img_width' => intval( $this->
width ),
1347 'img_height' => intval( $this->height ),
1348 'img_bits' => $this->bits,
1349 'img_media_type' => $this->media_type,
1350 'img_major_mime' => $this->major_mime,
1351 'img_minor_mime' => $this->minor_mime,
1353 'img_user' =>
$user->getId(),
1354 'img_user_text' =>
$user->getName(),
1355 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
1361 $reupload = ( $dbw->affectedRows() == 0 );
1364 if ( $allowTimeKludge ) {
1365 # Use LOCK IN SHARE MODE to ignore any transaction snapshotting
1366 $ltimestamp = $dbw->selectField(
1369 [
'img_name' => $this->
getName() ],
1371 [
'LOCK IN SHARE MODE' ]
1373 $lUnixtime = $ltimestamp ?
wfTimestamp( TS_UNIX, $ltimestamp ) :
false;
1374 # Avoid a timestamp that is not newer than the last version
1375 # TODO: the image/oldimage tables should be like page/revision with an ID field
1378 $timestamp = $dbw->timestamp( $lUnixtime + 1 );
1385 'oi_name' =>
'img_name',
1386 'oi_archive_name' => $dbw->addQuotes( $oldver ),
1387 'oi_size' =>
'img_size',
1388 'oi_width' =>
'img_width',
1389 'oi_height' =>
'img_height',
1390 'oi_bits' =>
'img_bits',
1391 'oi_timestamp' =>
'img_timestamp',
1392 'oi_user' =>
'img_user',
1393 'oi_user_text' =>
'img_user_text',
1394 'oi_metadata' =>
'img_metadata',
1395 'oi_media_type' =>
'img_media_type',
1396 'oi_major_mime' =>
'img_major_mime',
1397 'oi_minor_mime' =>
'img_minor_mime',
1398 'oi_sha1' =>
'img_sha1',
1403 $fields[
'oi_description'] =
'img_description';
1406 $tables[] =
'image_comment_temp';
1407 $fields[
'oi_description_id'] =
'imgcomment_description_id';
1408 $joins[
'image_comment_temp'] = [
1410 [
'imgcomment_name = img_name' ]
1420 $res = $dbw->select(
1421 [
'image',
'image_comment_temp' ],
1422 [
'img_name',
'img_description' ],
1423 [
'img_name' => $this->
getName(),
'imgcomment_name' =>
null ],
1426 [
'image_comment_temp' => [
'LEFT JOIN', [
'imgcomment_name = img_name' ] ] ]
1428 foreach (
$res as $row ) {
1429 list( , $callback ) = $commentStore->insertWithTempTable( $dbw, $row->img_description );
1430 $callback( $row->img_name );
1434 # (T36993) Note: $oldver can be empty here, if the previous
1435 # version of the file was broken. Allow registration of the new
1436 # version to continue anyway, because that's better than having
1437 # an image that's not fixable by user operations.
1438 # Collision, this is an update of a file
1439 # Insert previous contents into oldimage
1440 $dbw->insertSelect(
'oldimage',
$tables, $fields,
1441 [
'img_name' => $this->
getName() ], __METHOD__, [], [], $joins );
1443 # Update the current image row
1444 $dbw->update(
'image',
1446 'img_size' => $this->size,
1447 'img_width' => intval( $this->
width ),
1448 'img_height' => intval( $this->height ),
1449 'img_bits' => $this->bits,
1450 'img_media_type' => $this->media_type,
1451 'img_major_mime' => $this->major_mime,
1452 'img_minor_mime' => $this->minor_mime,
1454 'img_user' =>
$user->getId(),
1455 'img_user_text' =>
$user->getName(),
1456 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
1459 [
'img_name' => $this->
getName() ],
1464 $dbw->delete(
'image_comment_temp', [
'imgcomment_name' => $this->
getName() ], __METHOD__ );
1467 $commentCallback( $this->
getName() );
1470 $descId = $descTitle->getArticleID();
1472 $wikiPage->setFile( $this );
1475 $logEntry =
new ManualLogEntry(
'upload', $reupload ?
'overwrite' :
'upload' );
1476 $logEntry->setTimestamp( $this->timestamp );
1477 $logEntry->setPerformer(
$user );
1478 $logEntry->setComment( $comment );
1479 $logEntry->setTarget( $descTitle );
1482 $logEntry->setParameters(
1484 'img_sha1' => $this->sha1,
1494 $logId = $logEntry->insert();
1496 if ( $descTitle->exists() ) {
1500 $editSummary = $formatter->getPlainActionText();
1509 if ( $nullRevision ) {
1510 $nullRevision->insertOn( $dbw );
1512 'NewRevisionFromEditComplete',
1513 [ $wikiPage, $nullRevision, $nullRevision->getParentId(),
$user ]
1515 $wikiPage->updateRevisionOn( $dbw, $nullRevision );
1517 $logEntry->setAssociatedRevId( $nullRevision->getId() );
1520 $newPageContent =
null;
1526 # Defer purges, page creation, and link updates in case they error out.
1527 # The most important thing is that files and the DB registry stay synced.
1528 $dbw->endAtomic( __METHOD__ );
1530 # Do some cache purges after final commit so that:
1531 # a) Changes are more likely to be seen post-purge
1532 # b) They won't cause rollback of the log publish/update above
1538 $reupload, $wikiPage, $newPageContent, $comment,
$user,
1539 $logEntry, $logId, $descId, $tags
1541 # Update memcache after the commit
1544 $updateLogPage =
false;
1545 if ( $newPageContent ) {
1546 # New file page; create the description page.
1547 # There's already a log entry, so don't make a second RC entry
1548 # CDN and file cache for the description page are purged by doEditContent.
1549 $status = $wikiPage->doEditContent(
1557 if ( isset(
$status->value[
'revision'] ) ) {
1561 $logEntry->setAssociatedRevId(
$rev->getId() );
1565 if ( isset(
$status->value[
'revision'] ) ) {
1568 $updateLogPage =
$rev->getPage();
1571 # Existing file page: invalidate description page cache
1572 $wikiPage->getTitle()->invalidateCache();
1573 $wikiPage->getTitle()->purgeSquid();
1574 # Allow the new file version to be patrolled from the page footer
1578 # Update associated rev id. This should be done by $logEntry->insert() earlier,
1579 # but setAssociatedRevId() wasn't called at that point yet...
1580 $logParams = $logEntry->getParameters();
1581 $logParams[
'associated_rev_id'] = $logEntry->getAssociatedRevId();
1583 if ( $updateLogPage ) {
1584 # Also log page, in case where we just created it above
1585 $update[
'log_page'] = $updateLogPage;
1587 $this->
getRepo()->getMasterDB()->update(
1590 [
'log_id' => $logId ],
1593 $this->
getRepo()->getMasterDB()->insert(
1596 'ls_field' =>
'associated_rev_id',
1597 'ls_value' => $logEntry->getAssociatedRevId(),
1598 'ls_log_id' => $logId,
1603 # Add change tags, if any
1605 $logEntry->setTags( $tags );
1608 # Uploads can be patrolled
1609 $logEntry->setIsPatrollable(
true );
1611 # Now that the log entry is up-to-date, make an RC entry.
1612 $logEntry->publish( $logId );
1614 # Run hook for other updates (typically more cache purging)
1615 Hooks::run(
'FileUpload', [ $this, $reupload, !$newPageContent ] );
1618 # Delete old thumbnails
1620 # Remove the old file from the CDN cache
1626 # Update backlink pages pointing to this title if created
1637 # This is a new file, so update the image count
1641 # Invalidate cache for all pages using this file
1682 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
1692 $archiveRel =
'archive/' . $this->
getHashPath() . $archiveName;
1700 $dst = $wrapperBackend->getPathForSHA1(
$sha1 );
1707 $status->value = $archiveName;
1713 if (
$status->value ==
'new' ) {
1716 $status->value = $archiveName;
1743 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1747 wfDebugLog(
'imagemove',
"Got request to move {$this->name} to " . $target->getText() );
1751 $batch->addCurrent();
1752 $archiveNames =
$batch->addOlds();
1756 wfDebugLog(
'imagemove',
"Finished moving {$this->name}" );
1764 $this->
getRepo()->getMasterDB(),
1766 function ()
use ( $oldTitleFile, $newTitleFile, $archiveNames ) {
1767 $oldTitleFile->purgeEverything();
1768 foreach ( $archiveNames
as $archiveName ) {
1769 $oldTitleFile->purgeOldThumbnails( $archiveName );
1771 $newTitleFile->purgeEverything();
1779 $this->
title = $target;
1781 unset( $this->
name );
1782 unset( $this->hashPath );
1801 function delete( $reason, $suppress =
false,
$user = null ) {
1802 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1811 $archiveNames =
$batch->addOlds();
1822 $this->
getRepo()->getMasterDB(),
1824 function ()
use ( $archiveNames ) {
1826 foreach ( $archiveNames
as $archiveName ) {
1836 foreach ( $archiveNames
as $archiveName ) {
1860 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1867 $batch->addOld( $archiveName );
1895 function restore( $versions = [], $unsuppress =
false ) {
1896 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1906 $batch->addIds( $versions );
1910 $cleanupStatus =
$batch->cleanup();
1911 $cleanupStatus->successCount = 0;
1912 $cleanupStatus->failCount = 0;
1913 $status->merge( $cleanupStatus );
1930 return $this->
title->getLocalURL();
1946 $content = $revision->getContent();
1952 return $pout->getText();
1962 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_COMMENT ) ) {
1964 } elseif ( $audience == self::FOR_THIS_USER
1989 if ( $this->descriptionTouched ===
null ) {
1991 'page_namespace' => $this->
title->getNamespace(),
1992 'page_title' => $this->
title->getDBkey()
1994 $touched = $this->repo->getReplicaDB()->selectField(
'page',
'page_touched', $cond, __METHOD__ );
1995 $this->descriptionTouched = $touched ?
wfTimestamp( TS_MW, $touched ) :
false;
2007 if ( $this->sha1 ==
'' && $this->fileExists ) {
2010 $this->sha1 = $this->repo->getFileSha1( $this->
getPath() );
2011 if ( !
wfReadOnly() && strval( $this->sha1 ) !=
'' ) {
2012 $dbw = $this->repo->getMasterDB();
2013 $dbw->update(
'image',
2014 [
'img_sha1' => $this->sha1 ],
2015 [
'img_name' => $this->
getName() ],
2033 return $this->extraDataLoaded
2042 return $this->
getRepo()->getBackend()->lockFiles(
2052 return $this->
getRepo()->getBackend()->unlockFiles(
2067 if ( !$this->locked ) {
2068 $logger = LoggerFactory::getInstance(
'LocalFile' );
2070 $dbw = $this->repo->getMasterDB();
2071 $makesTransaction = !$dbw->trxLevel();
2072 $dbw->startAtomic( self::ATOMIC_SECTION_LOCK );
2078 $dbw->endAtomic( self::ATOMIC_SECTION_LOCK );
2079 $logger->warning(
"Failed to lock '{file}'", [
'file' => $this->
name ] );
2085 $dbw->onTransactionResolution(
2086 function ()
use ( $logger ) {
2089 $logger->error(
"Failed to unlock '{file}'", [
'file' => $this->
name ] );
2095 $this->lockedOwnTrx = $makesTransaction;
2112 if ( $this->locked ) {
2114 if ( !$this->locked ) {
2115 $dbw = $this->repo->getMasterDB();
2116 $dbw->endAtomic( self::ATOMIC_SECTION_LOCK );
2117 $this->lockedOwnTrx =
false;
2126 return $this->
getRepo()->newFatal(
'filereadonlyerror', $this->
getName(),
2138 # ------------------------------------------------------------------------------
2185 $this->status =
$file->repo->newGood();
2189 $this->srcRels[
'.'] = $this->
file->getRel();
2196 $this->srcRels[$oldName] = $this->
file->getArchiveRel( $oldName );
2197 $this->archiveUrls[] = $this->
file->getArchiveUrl( $oldName );
2207 $dbw = $this->
file->repo->getMasterDB();
2208 $result = $dbw->select(
'oldimage',
2209 [
'oi_archive_name' ],
2210 [
'oi_name' => $this->
file->getName() ],
2215 $this->
addOld( $row->oi_archive_name );
2216 $archiveNames[] = $row->oi_archive_name;
2219 return $archiveNames;
2226 if ( !isset( $this->srcRels[
'.'] ) ) {
2228 $deleteCurrent =
false;
2231 unset( $oldRels[
'.'] );
2232 $deleteCurrent =
true;
2235 return [ $oldRels, $deleteCurrent ];
2245 if ( $deleteCurrent ) {
2249 if (
count( $oldRels ) ) {
2250 $dbw = $this->
file->repo->getMasterDB();
2251 $res = $dbw->select(
2253 [
'oi_archive_name',
'oi_sha1' ],
2254 [
'oi_archive_name' => array_keys( $oldRels ),
2255 'oi_name' => $this->
file->getName() ],
2259 foreach (
$res as $row ) {
2260 if ( rtrim( $row->oi_sha1,
"\0" ) ===
'' ) {
2262 $oldUrl = $this->
file->getArchiveVirtualUrl( $row->oi_archive_name );
2263 $props = $this->
file->repo->getFileProps( $oldUrl );
2265 if ( $props[
'fileExists'] ) {
2267 $dbw->update(
'oldimage',
2268 [
'oi_sha1' => $props[
'sha1'] ],
2269 [
'oi_name' => $this->
file->getName(),
'oi_archive_name' => $row->oi_archive_name ],
2271 $hashes[$row->oi_archive_name] = $props[
'sha1'];
2273 $hashes[$row->oi_archive_name] =
false;
2276 $hashes[$row->oi_archive_name] = $row->oi_sha1;
2281 $missing = array_diff_key( $this->srcRels,
$hashes );
2283 foreach ( $missing
as $name => $rel ) {
2284 $this->status->error(
'filedelete-old-unregistered',
$name );
2289 $this->status->error(
'filedelete-missing', $this->srcRels[
$name] );
2301 $dbw = $this->
file->repo->getMasterDB();
2303 $commentStoreImgDesc =
new CommentStore(
'img_description' );
2304 $commentStoreOiDesc =
new CommentStore(
'oi_description' );
2305 $commentStoreFaDesc =
new CommentStore(
'fa_description' );
2306 $commentStoreFaReason =
new CommentStore(
'fa_deleted_reason' );
2308 $encTimestamp = $dbw->addQuotes( $dbw->timestamp( $now ) );
2309 $encUserId = $dbw->addQuotes( $this->
user->getId() );
2310 $encGroup = $dbw->addQuotes(
'deleted' );
2311 $ext = $this->
file->getExtension();
2312 $dotExt =
$ext ===
'' ?
'' :
".$ext";
2313 $encExt = $dbw->addQuotes( $dotExt );
2317 if ( $this->suppress ) {
2320 $bitfield =
'oi_deleted';
2323 if ( $deleteCurrent ) {
2326 'fa_storage_group' => $encGroup,
2327 'fa_storage_key' => $dbw->conditional(
2328 [
'img_sha1' =>
'' ],
2329 $dbw->addQuotes(
'' ),
2330 $dbw->buildConcat( [
"img_sha1", $encExt ] )
2332 'fa_deleted_user' => $encUserId,
2333 'fa_deleted_timestamp' => $encTimestamp,
2334 'fa_deleted' => $this->suppress ? $bitfield : 0,
2335 'fa_name' =>
'img_name',
2336 'fa_archive_name' =>
'NULL',
2337 'fa_size' =>
'img_size',
2338 'fa_width' =>
'img_width',
2339 'fa_height' =>
'img_height',
2340 'fa_metadata' =>
'img_metadata',
2341 'fa_bits' =>
'img_bits',
2342 'fa_media_type' =>
'img_media_type',
2343 'fa_major_mime' =>
'img_major_mime',
2344 'fa_minor_mime' =>
'img_minor_mime',
2345 'fa_user' =>
'img_user',
2346 'fa_user_text' =>
'img_user_text',
2347 'fa_timestamp' =>
'img_timestamp',
2348 'fa_sha1' =>
'img_sha1'
2352 $fields += array_map(
2353 [ $dbw,
'addQuotes' ],
2354 $commentStoreFaReason->insert( $dbw, $this->reason )
2358 $fields[
'fa_description'] =
'img_description';
2361 $tables[] =
'image_comment_temp';
2362 $fields[
'fa_description_id'] =
'imgcomment_description_id';
2363 $joins[
'image_comment_temp'] = [
2365 [
'imgcomment_name = img_name' ]
2375 $res = $dbw->select(
2376 [
'image',
'image_comment_temp' ],
2377 [
'img_name',
'img_description' ],
2378 [
'img_name' => $this->
file->getName(),
'imgcomment_name' => null ],
2381 [
'image_comment_temp' => [
'LEFT JOIN', [
'imgcomment_name = img_name' ] ] ]
2383 foreach (
$res as $row ) {
2384 list( , $callback ) = $commentStoreImgDesc->insertWithTempTable( $dbw, $row->img_description );
2385 $callback( $row->img_name );
2389 $dbw->insertSelect(
'filearchive',
$tables, $fields,
2390 [
'img_name' => $this->
file->getName() ], __METHOD__, [], [], $joins );
2393 if (
count( $oldRels ) ) {
2394 $res = $dbw->select(
2398 'oi_name' => $this->
file->getName(),
2399 'oi_archive_name' => array_keys( $oldRels )
2405 if (
$res->numRows() ) {
2406 $reason = $commentStoreFaReason->createComment( $dbw, $this->
reason );
2407 foreach (
$res as $row ) {
2409 $comment = $commentStoreOiDesc->getCommentLegacy( $dbw, $row );
2412 'fa_storage_group' =>
'deleted',
2413 'fa_storage_key' => ( $row->oi_sha1 ===
'' )
2415 :
"{$row->oi_sha1}{$dotExt}",
2416 'fa_deleted_user' => $this->
user->getId(),
2417 'fa_deleted_timestamp' => $dbw->timestamp( $now ),
2419 'fa_deleted' => $this->suppress ? $bitfield : $row->oi_deleted,
2420 'fa_name' => $row->oi_name,
2421 'fa_archive_name' => $row->oi_archive_name,
2422 'fa_size' => $row->oi_size,
2423 'fa_width' => $row->oi_width,
2424 'fa_height' => $row->oi_height,
2425 'fa_metadata' => $row->oi_metadata,
2426 'fa_bits' => $row->oi_bits,
2427 'fa_media_type' => $row->oi_media_type,
2428 'fa_major_mime' => $row->oi_major_mime,
2429 'fa_minor_mime' => $row->oi_minor_mime,
2430 'fa_user' => $row->oi_user,
2431 'fa_user_text' => $row->oi_user_text,
2432 'fa_timestamp' => $row->oi_timestamp,
2433 'fa_sha1' => $row->oi_sha1
2434 ] + $commentStoreFaReason->insert( $dbw,
$reason )
2435 + $commentStoreFaDesc->insert( $dbw, $comment );
2439 $dbw->insert(
'filearchive', $rowsInsert, __METHOD__ );
2446 $dbw = $this->
file->repo->getMasterDB();
2449 if (
count( $oldRels ) ) {
2450 $dbw->delete(
'oldimage',
2452 'oi_name' => $this->
file->getName(),
2453 'oi_archive_name' => array_keys( $oldRels )
2457 if ( $deleteCurrent ) {
2458 $dbw->delete(
'image', [
'img_name' => $this->
file->getName() ], __METHOD__ );
2461 'image_comment_temp', [
'imgcomment_name' => $this->
file->getName() ], __METHOD__
2472 $repo = $this->
file->getRepo();
2473 $this->
file->lock();
2477 $this->deletionBatch = [];
2478 $ext = $this->
file->getExtension();
2479 $dotExt =
$ext ===
'' ?
'' :
".$ext";
2481 foreach ( $this->srcRels
as $name => $srcRel ) {
2485 $key = $hash . $dotExt;
2486 $dstRel = $repo->getDeletedHashPath( $key ) . $key;
2487 $this->deletionBatch[
$name] = [ $srcRel, $dstRel ];
2491 if ( !$repo->hasSha1Storage() ) {
2495 if ( !$checkStatus->isGood() ) {
2496 $this->status->merge( $checkStatus );
2499 $this->deletionBatch = $checkStatus->value;
2502 $status = $this->
file->repo->deleteBatch( $this->deletionBatch );
2504 $this->status->merge(
$status );
2508 if ( !$this->status->isOK() ) {
2510 $this->
file->unlock();
2521 $this->
file->unlock();
2532 $files = $newBatch = [];
2535 list( $src, ) = $batchItem;
2536 $files[$src] = $this->
file->repo->getVirtualUrl(
'public' ) .
'/' . rawurlencode( $src );
2539 $result = $this->
file->repo->fileExistsBatch( $files );
2540 if ( in_array(
null,
$result,
true ) ) {
2542 $this->
file->repo->getBackend()->getName() );
2546 if (
$result[$batchItem[0]] ) {
2547 $newBatch[] = $batchItem;
2555 # ------------------------------------------------------------------------------
2583 $this->cleanupBatch = $this->ids = [];
2593 $this->ids[] = $fa_id;
2601 $this->ids = array_merge( $this->ids,
$ids );
2623 $repo = $this->
file->getRepo();
2624 if ( !$this->all && !$this->ids ) {
2626 return $repo->newGood();
2629 $lockOwnsTrx = $this->
file->lock();
2631 $dbw = $this->
file->repo->getMasterDB();
2633 $commentStoreImgDesc =
new CommentStore(
'img_description' );
2634 $commentStoreOiDesc =
new CommentStore(
'oi_description' );
2635 $commentStoreFaDesc =
new CommentStore(
'fa_description' );
2639 $exists = (bool)$dbw->selectField(
'image',
'1',
2640 [
'img_name' => $this->file->getName() ],
2645 $lockOwnsTrx ? [] : [
'LOCK IN SHARE MODE' ]
2650 $conditions = [
'fa_name' => $this->
file->getName() ];
2652 if ( !$this->all ) {
2661 [
'ORDER BY' =>
'fa_timestamp DESC' ]
2667 $insertCurrent =
false;
2673 $idsPresent[] = $row->fa_id;
2675 if ( $row->fa_name != $this->file->getName() ) {
2676 $status->error(
'undelete-filename-mismatch',
$wgLang->timeanddate( $row->fa_timestamp ) );
2681 if ( $row->fa_storage_key ==
'' ) {
2683 $status->error(
'undelete-bad-store-key',
$wgLang->timeanddate( $row->fa_timestamp ) );
2688 $deletedRel = $repo->getDeletedHashPath( $row->fa_storage_key ) .
2689 $row->fa_storage_key;
2690 $deletedUrl = $repo->getVirtualUrl() .
'/deleted/' . $deletedRel;
2692 if ( isset( $row->fa_sha1 ) ) {
2693 $sha1 = $row->fa_sha1;
2700 if ( strlen( $sha1 ) == 32 && $sha1[0] ==
'0' ) {
2701 $sha1 = substr( $sha1, 1 );
2704 if ( is_null( $row->fa_major_mime ) || $row->fa_major_mime ==
'unknown'
2705 || is_null( $row->fa_minor_mime ) || $row->fa_minor_mime ==
'unknown'
2706 || is_null( $row->fa_media_type ) || $row->fa_media_type ==
'UNKNOWN'
2707 || is_null( $row->fa_metadata )
2714 'minor_mime' => $row->fa_minor_mime,
2715 'major_mime' => $row->fa_major_mime,
2716 'media_type' => $row->fa_media_type,
2717 'metadata' => $row->fa_metadata
2722 $comment = $commentStoreFaDesc->getCommentLegacy( $dbw, $row );
2723 if ( $first && !$exists ) {
2725 $destRel = $this->
file->getRel();
2726 list( $commentFields, $commentCallback ) =
2727 $commentStoreImgDesc->insertWithTempTable( $dbw, $comment );
2729 'img_name' => $row->fa_name,
2730 'img_size' => $row->fa_size,
2731 'img_width' => $row->fa_width,
2732 'img_height' => $row->fa_height,
2733 'img_metadata' => $props[
'metadata'],
2734 'img_bits' => $row->fa_bits,
2735 'img_media_type' => $props[
'media_type'],
2736 'img_major_mime' => $props[
'major_mime'],
2737 'img_minor_mime' => $props[
'minor_mime'],
2738 'img_user' => $row->fa_user,
2739 'img_user_text' => $row->fa_user_text,
2740 'img_timestamp' => $row->fa_timestamp,
2745 if ( !$this->unsuppress && $row->fa_deleted ) {
2746 $status->fatal(
'undeleterevdel' );
2747 $this->
file->unlock();
2751 $archiveName = $row->fa_archive_name;
2753 if ( $archiveName ==
'' ) {
2757 $timestamp =
wfTimestamp( TS_UNIX, $row->fa_deleted_timestamp );
2760 $archiveName =
wfTimestamp( TS_MW, $timestamp ) .
'!' . $row->fa_name;
2762 }
while ( isset( $archiveNames[$archiveName] ) );
2765 $archiveNames[$archiveName] =
true;
2766 $destRel = $this->
file->getArchiveRel( $archiveName );
2768 'oi_name' => $row->fa_name,
2769 'oi_archive_name' => $archiveName,
2770 'oi_size' => $row->fa_size,
2771 'oi_width' => $row->fa_width,
2772 'oi_height' => $row->fa_height,
2773 'oi_bits' => $row->fa_bits,
2774 'oi_user' => $row->fa_user,
2775 'oi_user_text' => $row->fa_user_text,
2776 'oi_timestamp' => $row->fa_timestamp,
2777 'oi_metadata' => $props[
'metadata'],
2778 'oi_media_type' => $props[
'media_type'],
2779 'oi_major_mime' => $props[
'major_mime'],
2780 'oi_minor_mime' => $props[
'minor_mime'],
2781 'oi_deleted' => $this->unsuppress ? 0 : $row->fa_deleted,
2783 ] + $commentStoreOiDesc->insert( $dbw, $comment );
2786 $deleteIds[] = $row->fa_id;
2792 $storeBatch[] = [ $deletedUrl,
'public', $destRel ];
2793 $this->cleanupBatch[] = $row->fa_storage_key;
2802 $missingIds = array_diff( $this->ids, $idsPresent );
2804 foreach ( $missingIds
as $id ) {
2805 $status->error(
'undelete-missing-filearchive', $id );
2808 if ( !$repo->hasSha1Storage() ) {
2811 if ( !$checkStatus->isGood() ) {
2812 $status->merge( $checkStatus );
2815 $storeBatch = $checkStatus->value;
2820 $status->merge( $storeStatus );
2827 $this->
file->unlock();
2839 if ( $insertCurrent ) {
2840 $dbw->insert(
'image', $insertCurrent, __METHOD__ );
2841 $commentCallback( $insertCurrent[
'img_name'] );
2844 if ( $insertBatch ) {
2845 $dbw->insert(
'oldimage', $insertBatch, __METHOD__ );
2849 $dbw->delete(
'filearchive',
2850 [
'fa_id' => $deleteIds ],
2855 if (
$status->successCount > 0 || !$storeBatch || $repo->hasSha1Storage() ) {
2857 wfDebug( __METHOD__ .
" restored {$status->successCount} items, creating a new current\n" );
2861 $this->
file->purgeEverything();
2863 wfDebug( __METHOD__ .
" restored {$status->successCount} as archived versions\n" );
2864 $this->
file->purgeDescription();
2868 $this->
file->unlock();
2879 $files = $filteredTriplets = [];
2880 foreach ( $triplets
as $file ) {
2884 $result = $this->
file->repo->fileExistsBatch( $files );
2885 if ( in_array(
null,
$result,
true ) ) {
2887 $this->
file->repo->getBackend()->getName() );
2890 foreach ( $triplets
as $file ) {
2892 $filteredTriplets[] =
$file;
2905 $files = $newBatch = [];
2906 $repo = $this->
file->repo;
2909 $files[
$file] = $repo->getVirtualUrl(
'deleted' ) .
'/' .
2910 rawurlencode( $repo->getDeletedHashPath(
$file ) .
$file );
2913 $result = $repo->fileExistsBatch( $files );
2917 $newBatch[] =
$file;
2930 if ( !$this->cleanupBatch ) {
2931 return $this->
file->repo->newGood();
2936 $status = $this->
file->repo->cleanupDeletedBatch( $this->cleanupBatch );
2951 foreach ( $storeStatus->success
as $i =>
$success ) {
2956 $cleanupBatch[] = [ $storeBatch[$i][1], $storeBatch[$i][2] ];
2963 # ------------------------------------------------------------------------------
2994 $this->oldHash = $this->
file->repo->getHashPath( $this->
file->getName() );
2995 $this->newHash = $this->
file->repo->getHashPath( $this->target->getDBkey() );
2996 $this->oldName = $this->
file->getName();
2997 $this->newName = $this->
file->repo->getNameFromTitle( $this->target );
2998 $this->oldRel = $this->oldHash . $this->oldName;
2999 $this->newRel = $this->newHash . $this->newName;
3007 $this->cur = [ $this->oldRel, $this->newRel ];
3015 $archiveBase =
'archive';
3017 $this->oldCount = 0;
3020 $result = $this->db->select(
'oldimage',
3021 [
'oi_archive_name',
'oi_deleted' ],
3022 [
'oi_name' => $this->oldName ],
3024 [
'LOCK IN SHARE MODE' ]
3028 $archiveNames[] = $row->oi_archive_name;
3029 $oldName = $row->oi_archive_name;
3030 $bits = explode(
'!', $oldName, 2 );
3032 if (
count( $bits ) != 2 ) {
3033 wfDebug(
"Old file name missing !: '$oldName' \n" );
3037 list( $timestamp, $filename ) = $bits;
3039 if ( $this->oldName != $filename ) {
3040 wfDebug(
"Old file name doesn't match: '$oldName' \n" );
3052 "{$archiveBase}/{$this->oldHash}{$oldName}",
3053 "{$archiveBase}/{$this->newHash}{$timestamp}!{$this->newName}"
3057 return $archiveNames;
3065 $repo = $this->
file->repo;
3069 $this->
file->lock();
3074 if ( !$checkStatus->isGood() ) {
3075 $destFile->unlock();
3076 $this->
file->unlock();
3077 $status->merge( $checkStatus );
3080 $triplets = $checkStatus->value;
3084 if ( !$statusDb->isGood() ) {
3085 $destFile->unlock();
3086 $this->
file->unlock();
3087 $statusDb->setOK(
false );
3092 if ( !$repo->hasSha1Storage() ) {
3097 wfDebugLog(
'imagemove',
"Moved files for {$this->file->getName()}: " .
3098 "{$statusMove->successCount} successes, {$statusMove->failCount} failures" );
3099 if ( !$statusMove->isGood() ) {
3102 $destFile->unlock();
3103 $this->
file->unlock();
3104 wfDebugLog(
'imagemove',
"Error in moving files: "
3105 . $statusMove->getWikiText(
false,
false,
'en' ) );
3106 $statusMove->setOK(
false );
3110 $status->merge( $statusMove );
3116 wfDebugLog(
'imagemove',
"Renamed {$this->file->getName()} in database: " .
3117 "{$statusDb->successCount} successes, {$statusDb->failCount} failures" );
3119 $destFile->unlock();
3120 $this->
file->unlock();
3137 $repo = $this->
file->repo;
3144 [
'img_name' => $this->oldName ],
3148 $oldRowCount = $dbw->selectField(
3151 [
'oi_name' => $this->oldName ],
3156 if ( $hasCurrent ) {
3161 $status->successCount += $oldRowCount;
3165 $status->failCount += max( 0, $this->oldCount - $oldRowCount );
3167 $status->error(
'imageinvalidfilename' );
3183 [
'img_name' => $this->newName ],
3184 [
'img_name' => $this->oldName ],
3191 'oi_name' => $this->newName,
3192 'oi_archive_name = ' . $dbw->strreplace(
'oi_archive_name',
3193 $dbw->addQuotes( $this->oldName ), $dbw->addQuotes( $this->newName ) ),
3195 [
'oi_name' => $this->oldName ],
3205 $moves = array_merge( [ $this->cur ], $this->olds );
3208 foreach ( $moves
as $move ) {
3210 $srcUrl = $this->
file->repo->getVirtualUrl() .
'/public/' . rawurlencode( $move[0] );
3211 $triplets[] = [ $srcUrl,
'public', $move[1] ];
3214 "Generated move triplet for {$this->file->getName()}: {$srcUrl} :: public :: {$move[1]}"
3229 foreach ( $triplets
as $file ) {
3233 $result = $this->
file->repo->fileExistsBatch( $files );
3234 if ( in_array(
null,
$result,
true ) ) {
3236 $this->
file->repo->getBackend()->getName() );
3239 $filteredTriplets = [];
3240 foreach ( $triplets
as $file ) {
3242 $filteredTriplets[] =
$file;
3244 wfDebugLog(
'imagemove',
"File {$file[0]} does not exist" );
3259 foreach ( $triplets
as $triplet ) {
3261 $pairs[] = [ $triplet[1], $triplet[2] ];
3264 $this->
file->repo->cleanupBatch( $pairs );
3275 foreach ( $triplets
as $triplet ) {
3276 $files[] = $triplet[0];
3279 $this->
file->repo->cleanupBatch( $files );
3285 parent::__construct(
3293 $wgOut->setStatusCode( 429 );
string $media_type
MEDIATYPE_xxx (bitmap, drawing, audio...)
Set options of the Parser.
const ATOMIC_SECTION_LOCK
bool $fileExists
Does the file exist on disk? (loadFromXxx)
getPath()
Return the storage path to the file.
$wgUpdateCompatibleMetadata
If to automatically update the img_metadata field if the metadata field is outdated but compatible wi...
static getInitialPageText( $comment='', $license='', $copyStatus='', $source='', Config $config=null)
Get the initial image page text based on a comment and optional file status information.
maybeUpgradeRow()
Upgrade a row if it needs it.
Helper class for file undeletion.
array $deletionBatch
Items to be processed in the deletion batch.
getMutableCacheKeys(WANObjectCache $cache)
getReadOnlyReason()
Get an explanatory message if this repo is read-only.
unprefixRow( $row, $prefix='img_')
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
getArchiveThumbPath( $archiveName, $suffix=false)
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified.
static singleton()
Get a RepoGroup instance.
processing should stop and the error should be shown to the user * false
__construct( $title, $repo)
Do not call this except from inside a repo class.
unlock()
Decrement the lock reference count and end the atomic section if it reaches zero.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
isMultipage()
Returns 'true' if this file is a type which supports multiple pages, e.g.
getUser( $type='text')
Returns ID or name of user who uploaded the file.
loadFromDB( $flags=0)
Load file metadata from the DB.
if(!isset( $args[0])) $lang
purgeThumbList( $dir, $files)
Delete a list of thumbnails visible at urls.
getRel()
Get the path of the file relative to the public zone root.
cleanupSource( $triplets)
Cleanup a fully moved array of triplets by deleting the source files.
Deferrable Update for closure/callback updates that should use auto-commit mode.
bool $missing
True if file is not present in file system.
Helper class for file deletion.
int $wgCommentTableSchemaMigrationStage
Comment table schema migration stage.
execute()
Run the transaction, except the cleanup batch.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
addId( $fa_id)
Add a file by ID.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static queueRecursiveJobsForTable(Title $title, $table)
Queue a RefreshLinks job for any table.
verifyDBUpdates()
Verify the database updates and return a new Status indicating how many rows would be updated.
File backend exception for checked exceptions (e.g.
bool $upgraded
Whether the row was upgraded on load.
getDescriptionShortUrl()
Get short description URL for a file based on the page ID.
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
getCacheFields( $prefix='img_')
bool $all
Add all revisions of the file.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
int $user
User ID of uploader.
__construct(File $file, Title $target)
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
execute()
Run the transaction.
static newFatal( $message)
Factory function for fatal errors.
getHistory( $limit=null, $start=null, $end=null, $inc=true)
purgeDescription inherited
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
getMediaType()
Returns the type of the media in the file.
getUrl()
Return the URL of the file.
bool $dataLoaded
Whether or not core data has been loaded from the database (loadFromXxx)
const MIGRATION_WRITE_BOTH
static newFromTitle( $title, $repo, $unused=null)
Create a LocalFile from a title Do not call this except from inside a repo class.
wfReadOnly()
Check whether the wiki is in read-only mode.
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
bool $upgrading
Whether the row was scheduled to upgrade on load.
getSize()
Returns the size of the image file, in bytes.
static selectFields()
Fields in the oldimage table.
purgeOldThumbnails( $archiveName)
Delete cached transformed files for an archived version only.
int $historyRes
Result of the query for the file's history (nextHistoryLine)
Allows to change the fields on the form that will be generated $name
getThumbnails( $archiveName=false)
getTransformScript inherited
string $sha1
SHA-1 base 36 content hash.
static splitMime( $mime)
Split an internet media type into its two components; if not a two-part name, set the minor type to '...
__construct(File $file, $unsuppress=false)
string $minor_mime
Minor MIME type.
isDeleted( $field)
Is this file a "deleted" file in a private archive? STUB.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
static getHashFromKey( $key)
Gets the SHA1 hash from a storage key.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
publish( $src, $dstRel, $archiveRel, $flags=0, array $options=[])
Copy or move a file either from a storage path, virtual URL, or file system path, into this repositor...
Generic operation result class Has warning/error list, boolean status and arbitrary value.
addOlds()
Add the old versions of the image to the batch.
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 in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
decodeRow( $row, $prefix='img_')
Decode a row from the database (either object or array) to an array with timestamps and MIME types de...
int $bits
Returned by getimagesize (loadFromXxx)
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
cleanupFailedBatch( $storeStatus, $storeBatch)
Cleanup a failed batch.
static addCallableUpdate( $callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
purgeThumbnails( $options=[])
Delete cached transformed files for the current version only.
hasSha1Storage()
Returns whether or not storage is SHA-1 based.
Implements some public methods and some protected utility functions which are required by multiple ch...
loadExtraFromDB()
Load lazy file metadata from the DB.
publishTo( $src, $dstRel, $flags=0, array $options=[])
Move or copy a file to a specified location.
string $url
The URL corresponding to one of the four basic zones.
static newFromRow( $row, $repo)
Create a LocalFile from a title Do not call this except from inside a repo class.
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
purgeMetadataCache()
Refresh metadata in memcached, but don't touch thumbnails or CDN.
getThumbPath( $suffix=false)
Get the path of the thumbnail directory, or a particular file if $suffix is specified.
quickImport( $src, $dst, $options=null)
Import a file from the local file system into the repo.
static isStoragePath( $path)
Check if a given path is a "mwstore://" path.
deleteOld( $archiveName, $reason, $suppress=false, $user=null)
Delete an old version of the file.
__construct(Status $status)
const CACHE_FIELD_MAX_LEN
report()
Output a report about the exception and takes care of formatting.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
loadFromRow( $row, $prefix='img_')
Load file metadata from a DB result row.
__destruct()
Clean up any dangling locks.
int $deleted
Bitfield akin to rev_deleted.
$wgUploadThumbnailRenderMap
When defined, is an array of thumbnail widths to be rendered at upload time.
static getSha1Base36FromPath( $path)
Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding,...
loadFieldsWithTimestamp( $dbr, $fname)
bool $suppress
Whether to suppress all suppressable fields when deleting.
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
static factory(array $deltas)
MimeMagic helper wrapper.
prerenderThumbnails()
Prerenders a configurable set of thumbnails.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
getCacheKey()
Get the memcached key for the main data for this file, or false if there is no access to the shared c...
static singleton()
Get an instance of this class.
addAll()
Add all revisions of the file.
string $mime
MIME type, determined by MimeMagic::guessMimeType.
bool $unsuppress
Whether to remove all settings for suppressed fields.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
setProps( $info)
Set properties in this object to be equal to those given in the associative array $info.
getFileSha1( $virtualUrl)
Get the sha1 (base 36) of a file with a given virtual URL/storage path.
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
Class to represent a local file in the wiki's own database.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
getMimeType()
Returns the MIME type of the file.
getDescription( $audience=self::FOR_PUBLIC, User $user=null)
bool $extraDataLoaded
Whether or not lazy-loaded data has been loaded from the database.
Job for asynchronous rendering of thumbnails.
int $size
Size in bytes (loadFromXxx)
Class to invalidate the HTML cache of all the pages linking to a given title.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
purgeDescription()
Purge the file description page, but don't go after pages using the file.
lock()
Start an atomic DB section and lock the image for update or increments a reference counter if the loc...
Handles purging appropriate CDN URLs given a title (or titles)
assertTitleDefined()
Assert that $this->title is set to a Title.
static newGood( $value=null)
Factory function for good results.
int $historyLine
Number of line to return by nextHistoryLine() (constructor)
getMoveTriplets()
Generate triplets for FileRepo::storeBatch().
upgradeRow()
Fix assorted version-related problems with the image row by reloading it from the file.
load( $flags=0)
Load file metadata from cache or DB, unless already loaded.
Multi-datacenter aware caching interface.
static newFromKey( $sha1, $repo, $timestamp=false)
Create a LocalFile from a SHA-1 key Do not call this except from inside a repo class.
nextHistoryLine()
Returns the history of this file, line by line.
array $cleanupBatch
List of file IDs to restore.
string $metadata
Handler-specific metadata.
getArchiveThumbUrl( $archiveName, $suffix=false)
Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified.
getName()
Return the name of this file.
getArchiveUrl( $suffix=false)
Get the URL of the archive directory, or a particular file if $suffix is specified.
Class representing a non-directory file on the file system.
string $timestamp
Upload timestamp.
getBackend()
Get the file backend instance.
string $descriptionTouched
TS_MW timestamp of the last change of the file description.
addOlds()
Add the old versions of the image to the batch.
recordUpload( $oldver, $desc, $license='', $copyStatus='', $source='', $watch=false, $timestamp=false, User $user=null)
Record a file upload in the upload log and the image table.
recordUpload2( $oldver, $comment, $pageText, $props=false, $timestamp=false, $user=null, $tags=[])
Record a file upload in the upload log and the image table.
array $ids
List of file IDs to restore.
bool $locked
True if the image row is locked.
string $description
Description of current revision of the file.
getLazyCacheFields( $prefix='img_')
static selectFields()
Fields in the image table.
string $user_text
User name of uploader.
getTitle()
Return the associated title object.
Represents a title within MediaWiki.
getMetadata()
Get handler-specific metadata.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is and will automatically terminate your rights under this License parties who have received or from you under this License will not have their licenses terminated so long as such parties remain in full compliance You are not required to accept this since you have not signed it nothing else grants you permission to modify or distribute the Program or its derivative works These actions are prohibited by law if you do not accept this License by modifying or distributing the you indicate your acceptance of this License to do and all its terms and conditions for distributing or modifying the Program or works based on it Each time you redistribute the the recipient automatically receives a license from the original licensor to distribute or modify the Program subject to these terms and conditions You may not impose any further restrictions on the recipients exercise of the rights granted herein You are not responsible for enforcing compliance by third parties to this License as a consequence of a court judgment or allegation of patent infringement or for any other reason(not limited to patent issues)
addIds( $ids)
Add a whole lot of files by ID.
loadFromFile()
Load metadata from the file itself.
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
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
execute()
Perform the move.
static getMainWANInstance()
Get the main WAN cache object.
getDescriptionText( $lang=null)
Get the HTML text of the description page This is not used by ImagePage for local files,...
upload( $src, $comment, $pageText, $flags=0, $props=false, $timestamp=false, $user=null, $tags=[])
getHashPath inherited
resetHistory()
Reset the history pointer to the first element of the history.
removeNonexistentFiles( $triplets)
Removes non-existent files from move batch.
static makeParamBlob( $params)
Create a blob from a parameter array.
cleanup()
Delete unused files in the deleted zone.
static singleton( $wiki=false)
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
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
removeNonexistentFiles( $triplets)
Removes non-existent files from a store batch.
static isVirtualUrl( $url)
Determine if a string is an mwrepo:// URL.
Helper class for file movement.
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
Class for creating log entries manually, to inject them into the database.
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
Special handling for file pages.
string $name
The name of a file from its title object.
publish( $src, $flags=0, array $options=[])
Move or copy a file to its public location.
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
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
getRepo()
Returns the repository.
getWidth( $page=1)
Return the width of the image.
static selectFields()
Fields in the filearchive table.
getThumbUrl( $suffix=false)
Get the URL of the thumbnail directory, or a particular file if $suffix is specified.
string $major_mime
Major MIME type.
isVectorized()
Return true if the file is vectorized.
getHandler()
Get a MediaHandler instance for this file.
An error page which can definitely be safely rendered using the OutputPage.
getHeight( $page=1)
Return the height of the image.
isMissing()
splitMime inherited
invalidateCache()
Purge the file object/metadata cache.
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this file, if it's marked as d...
bool $lockedOwnTrx
True if the image row is locked with a lock initiated transaction.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
__construct(File $file, $reason='', $suppress=false, $user=null)
wfLocalFile( $title)
Get an object referring to a locally registered file.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getDescriptionUrl()
isMultipage inherited
move( $target)
getLinksTo inherited
addCurrent()
Add the current image to the batch.
removeNonexistentFiles( $batch)
Removes non-existent files from a deletion batch.
doDBUpdates()
Do the database updates and return a new Status indicating how many rows where updated.
restore( $versions=[], $unsuppress=false)
Restore all or specified deleted revisions to the given file.
Internationalisation code.
purgeEverything()
Purge metadata and all affected pages when the file is created, deleted, or majorly updated.
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
exists()
canRender inherited
the array() calling protocol came about after MediaWiki 1.4rc1.
getThumbnails()
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.
loadFromCache()
Try to load file metadata from memcached, falling back to the database.
purgeCache( $options=[])
Delete all previously generated thumbnails, refresh metadata in memcached and purge the CDN.
cleanupTarget( $triplets)
Cleanup a partially moved array of triplets by deleting the target files.
getVirtualUrl( $suffix=false)
Get the public zone virtual URL for a current version source file.
removeNonexistentFromCleanup( $batch)
Removes non-existent files from a cleanup batch.
static purgePatrolFooterCache( $articleID)
Purge the cache used to check if it is worth showing the patrol footer For example,...