Go to the documentation of this file.
27 define(
'MW_FILE_VERSION', 9 );
154 $file->loadFromRow( $row );
176 $row =
$dbr->selectRow(
'image', self::selectFields(), $conds, __METHOD__ );
214 $this->metadata =
'';
215 $this->historyLine = 0;
216 $this->historyRes =
null;
217 $this->dataLoaded =
false;
218 $this->extraDataLoaded =
false;
230 $hashedName = md5( $this->
getName() );
232 return $this->repo->getSharedCacheKey(
'file', $hashedName );
243 $this->dataLoaded =
false;
244 $this->extraDataLoaded =
false;
253 $cachedValues =
$wgMemc->get( $key );
256 if ( isset( $cachedValues[
'version'] ) && $cachedValues[
'version'] ==
MW_FILE_VERSION ) {
257 wfDebug(
"Pulling file metadata from cache key $key\n" );
258 $this->fileExists = $cachedValues[
'fileExists'];
259 if ( $this->fileExists ) {
262 $this->dataLoaded =
true;
263 $this->extraDataLoaded =
true;
265 $this->extraDataLoaded = $this->extraDataLoaded && isset( $cachedValues[$field] );
269 if ( $this->dataLoaded ) {
297 if ( $this->fileExists ) {
298 foreach ( $fields
as $field ) {
299 $cache[$field] = $this->$field;
307 if ( isset(
$cache[$field] ) && strlen(
$cache[$field] ) > 100 * 1024 ) {
313 $wgMemc->set( $key,
$cache, $this->fileExists ? 86400 * 7 : 86400 );
320 $props = $this->repo->getFileProps( $this->
getVirtualUrl() );
329 static $fields =
array(
'size',
'width',
'height',
'bits',
'media_type',
330 'major_mime',
'minor_mime',
'metadata',
'timestamp',
'sha1',
'user',
331 'user_text',
'description' );
332 static $results =
array();
334 if ( $prefix ==
'' ) {
338 if ( !isset( $results[$prefix] ) ) {
339 $prefixedFields =
array();
340 foreach ( $fields
as $field ) {
341 $prefixedFields[] = $prefix . $field;
343 $results[$prefix] = $prefixedFields;
346 return $results[$prefix];
354 static $fields =
array(
'metadata' );
355 static $results =
array();
357 if ( $prefix ==
'' ) {
361 if ( !isset( $results[$prefix] ) ) {
362 $prefixedFields =
array();
363 foreach ( $fields
as $field ) {
364 $prefixedFields[] = $prefix . $field;
366 $results[$prefix] = $prefixedFields;
369 return $results[$prefix];
376 # Polymorphic function name to distinguish foreign and local fetches
377 $fname = get_class( $this ) .
'::' . __FUNCTION__;
380 # Unconditionally set loaded=true, we don't want the accessors constantly rechecking
381 $this->dataLoaded =
true;
382 $this->extraDataLoaded =
true;
384 $dbr = $this->repo->getMasterDB();
391 $this->fileExists =
false;
402 # Polymorphic function name to distinguish foreign and local fetches
403 $fname = get_class( $this ) .
'::' . __FUNCTION__;
406 # Unconditionally set loaded=true, we don't want the accessors constantly rechecking
407 $this->extraDataLoaded =
true;
409 $dbr = $this->repo->getSlaveDB();
415 $dbr = $this->repo->getMasterDB();
426 throw new MWException(
"Could not find data for image '{$this->getName()}'." );
439 $array = (
array)$row;
440 $prefixLength = strlen( $prefix );
443 if ( substr(
key( $array ), 0, $prefixLength ) !== $prefix ) {
444 throw new MWException( __METHOD__ .
': incorrect $prefix parameter' );
468 $decoded[
'metadata'] = $this->repo->getSlaveDB()->decodeBlob( $decoded[
'metadata'] );
470 if ( empty( $decoded[
'major_mime'] ) ) {
471 $decoded[
'mime'] =
'unknown/unknown';
473 if ( !$decoded[
'minor_mime'] ) {
474 $decoded[
'minor_mime'] =
'unknown';
476 $decoded[
'mime'] = $decoded[
'major_mime'] .
'/' . $decoded[
'minor_mime'];
479 # Trim zero padding from char/binary field
480 $decoded[
'sha1'] = rtrim( $decoded[
'sha1'],
"\0" );
489 $this->dataLoaded =
true;
490 $this->extraDataLoaded =
true;
492 $array = $this->
decodeRow( $row, $prefix );
498 $this->fileExists =
true;
507 if ( !$this->dataLoaded ) {
512 $this->dataLoaded =
true;
514 if ( (
$flags & self::LOAD_ALL ) && !$this->extraDataLoaded ) {
523 global $wgUpdateCompatibleMetadata;
528 if ( is_null( $this->media_type ) ||
529 $this->mime ==
'image/svg'
532 $this->upgraded =
true;
541 $this->upgraded =
true;
561 # Don't destroy file info of missing files
562 if ( !$this->fileExists ) {
563 wfDebug( __METHOD__ .
": file does not exist, aborting\n" );
569 $dbw = $this->repo->getMasterDB();
577 wfDebug( __METHOD__ .
': upgrading ' . $this->
getName() .
" to the current schema\n" );
579 $dbw->update(
'image',
581 'img_size' => $this->size,
582 'img_width' => $this->width,
583 'img_height' => $this->height,
584 'img_bits' => $this->bits,
585 'img_media_type' => $this->media_type,
586 'img_major_mime' => $major,
587 'img_minor_mime' => $minor,
588 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
611 $this->dataLoaded =
true;
613 $fields[] =
'fileExists';
615 foreach ( $fields
as $field ) {
616 if ( isset( $info[$field] ) ) {
617 $this->$field = $info[$field];
622 if ( isset( $info[
'major_mime'] ) ) {
623 $this->mime =
"{$info['major_mime']}/{$info['minor_mime']}";
624 } elseif ( isset( $info[
'mime'] ) ) {
625 $this->mime = $info[
'mime'];
642 if ( $this->missing ===
null ) {
656 public function getWidth( $page = 1 ) {
666 return $dim[
'width'];
693 return $dim[
'height'];
713 if (
$type ==
'text' ) {
715 } elseif (
$type ==
'id' ) {
725 $this->
load( self::LOAD_ALL );
779 public function exists() {
834 if ( $archiveName ) {
840 $backend = $this->repo->getBackend();
843 $iterator = $backend->getFileList(
array(
'dir' =>
$dir ) );
844 foreach ( $iterator
as $file ) {
870 $hashedName = md5( $this->
getName() );
871 $oldKey = $this->repo->getSharedCacheKey(
'oldfile', $hashedName );
910 wfRunHooks(
'LocalFilePurgeThumbnails',
array( $this, $archiveName ) );
942 array_shift( $urls );
946 if ( !empty(
$options[
'forThumbRefresh'] ) ) {
973 $fileListDebug = strtr(
974 var_export(
$files,
true ),
977 wfDebug( __METHOD__ .
": $fileListDebug\n" );
979 $purgeList =
array();
981 # Check that the base file name is part of the thumb name
982 # This is a basic sanity check to avoid erasing unrelated directories
984 || strpos(
$file,
"-thumbnail" ) !==
false
986 $purgeList[] =
"{$dir}/{$file}";
990 # Delete the thumbnails
991 $this->repo->quickPurgeBatch( $purgeList );
992 # Clear out the thumbnail directory if empty
993 $this->repo->quickCleanDir(
$dir );
1006 function getHistory(
$limit =
null, $start =
null, $end =
null, $inc =
true ) {
1007 $dbr = $this->repo->getSlaveDB();
1010 $conds = $opts = $join_conds =
array();
1011 $eq = $inc ?
'=' :
'';
1012 $conds[] =
"oi_name = " .
$dbr->addQuotes( $this->
title->getDBkey() );
1015 $conds[] =
"oi_timestamp <$eq " .
$dbr->addQuotes(
$dbr->timestamp( $start ) );
1019 $conds[] =
"oi_timestamp >$eq " .
$dbr->addQuotes(
$dbr->timestamp( $end ) );
1027 $order = ( !$start && $end !== null ) ?
'ASC' :
'DESC';
1028 $opts[
'ORDER BY'] =
"oi_timestamp $order";
1029 $opts[
'USE INDEX'] =
array(
'oldimage' =>
'oi_name_timestamp' );
1032 &$conds, &$opts, &$join_conds ) );
1034 $res =
$dbr->select(
$tables, $fields, $conds, __METHOD__, $opts, $join_conds );
1037 foreach (
$res as $row ) {
1038 $r[] = $this->repo->newFileFromRow( $row );
1041 if ( $order ==
'ASC' ) {
1042 $r = array_reverse( $r );
1058 # Polymorphic function name to distinguish foreign and local fetches
1059 $fname = get_class( $this ) .
'::' . __FUNCTION__;
1061 $dbr = $this->repo->getSlaveDB();
1063 if ( $this->historyLine == 0 ) {
1064 $this->historyRes =
$dbr->select(
'image',
1067 "'' AS oi_archive_name",
1071 array(
'img_name' => $this->
title->getDBkey() ),
1075 if ( 0 ==
$dbr->numRows( $this->historyRes ) ) {
1076 $this->historyRes =
null;
1080 } elseif ( $this->historyLine == 1 ) {
1081 $this->historyRes =
$dbr->select(
'oldimage',
'*',
1082 array(
'oi_name' => $this->
title->getDBkey() ),
1084 array(
'ORDER BY' =>
'oi_timestamp DESC' )
1087 $this->historyLine++;
1089 return $dbr->fetchObject( $this->historyRes );
1096 $this->historyLine = 0;
1098 if ( !is_null( $this->historyRes ) ) {
1099 $this->historyRes =
null;
1137 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1143 if ( $this->repo->isVirtualUrl( $srcPath )
1146 $props = $this->repo->getFileProps( $srcPath );
1170 if ( $status->successCount > 0 ) {
1171 # Essentially we are displacing any existing current file and saving
1172 # a new current file at the old location. If just the first succeeded,
1173 # we still need to displace the current DB entry and put in a new one.
1175 $status->fatal(
'filenotfound', $srcPath );
1231 if ( is_null(
$user ) ) {
1236 $dbw = $this->repo->getMasterDB();
1237 $dbw->begin( __METHOD__ );
1241 $props = $this->repo->getFileProps( $this->
getVirtualUrl() );
1250 $props[
'user'] =
$user->getId();
1251 $props[
'user_text'] =
$user->getName();
1255 # Fail now if the file isn't there
1256 if ( !$this->fileExists ) {
1257 wfDebug( __METHOD__ .
": File " . $this->
getRel() .
" went missing!\n" );
1265 # Test to see if the row exists using INSERT IGNORE
1266 # This avoids race conditions by locking the row until the commit, and also
1267 # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
1268 $dbw->insert(
'image',
1270 'img_name' => $this->
getName(),
1271 'img_size' => $this->size,
1272 'img_width' => intval( $this->width ),
1273 'img_height' => intval( $this->height ),
1274 'img_bits' => $this->bits,
1275 'img_media_type' => $this->media_type,
1276 'img_major_mime' => $this->major_mime,
1277 'img_minor_mime' => $this->minor_mime,
1280 'img_user' =>
$user->getId(),
1281 'img_user_text' =>
$user->getName(),
1282 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
1288 if ( $dbw->affectedRows() == 0 ) {
1289 # (bug 34993) Note: $oldver can be empty here, if the previous
1290 # version of the file was broken. Allow registration of the new
1291 # version to continue anyway, because that's better than having
1292 # an image that's not fixable by user operations.
1295 # Collision, this is an update of a file
1296 # Insert previous contents into oldimage
1297 $dbw->insertSelect(
'oldimage',
'image',
1299 'oi_name' =>
'img_name',
1300 'oi_archive_name' => $dbw->addQuotes( $oldver ),
1301 'oi_size' =>
'img_size',
1302 'oi_width' =>
'img_width',
1303 'oi_height' =>
'img_height',
1304 'oi_bits' =>
'img_bits',
1305 'oi_timestamp' =>
'img_timestamp',
1306 'oi_description' =>
'img_description',
1307 'oi_user' =>
'img_user',
1308 'oi_user_text' =>
'img_user_text',
1309 'oi_metadata' =>
'img_metadata',
1310 'oi_media_type' =>
'img_media_type',
1311 'oi_major_mime' =>
'img_major_mime',
1312 'oi_minor_mime' =>
'img_minor_mime',
1313 'oi_sha1' =>
'img_sha1'
1319 # Update the current image row
1320 $dbw->update(
'image',
1322 'img_size' => $this->size,
1323 'img_width' => intval( $this->width ),
1324 'img_height' => intval( $this->height ),
1325 'img_bits' => $this->bits,
1326 'img_media_type' => $this->media_type,
1327 'img_major_mime' => $this->major_mime,
1328 'img_minor_mime' => $this->minor_mime,
1331 'img_user' =>
$user->getId(),
1332 'img_user_text' =>
$user->getName(),
1333 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
1340 # This is a new file, so update the image count
1346 $wikiPage->setFile( $this );
1349 $action = $reupload ?
'overwrite' :
'upload';
1352 $logEntry->setPerformer(
$user );
1354 $logEntry->setTarget( $descTitle );
1358 $logEntry->setParameters(
1360 'img_sha1' => $this->sha1,
1370 $logId = $logEntry->insert();
1372 $exists = $descTitle->exists();
1375 $logEntry->publish( $logId );
1380 # Create a null revision
1381 $latest = $descTitle->getLatestRevID();
1386 $descTitle->getArticleID(),
1390 if ( !is_null( $nullRevision ) ) {
1391 $nullRevision->insertOn( $dbw );
1393 wfRunHooks(
'NewRevisionFromEditComplete',
array( $wikiPage, $nullRevision, $latest,
$user ) );
1394 $wikiPage->updateRevisionOn( $dbw, $nullRevision );
1398 # Commit the transaction now, in case something goes wrong later
1399 # The most important thing is that files don't get lost, especially archives
1400 # NOTE: once we have support for nested transactions, the commit may be moved
1401 # to after $wikiPage->doEdit has been called.
1402 $dbw->commit( __METHOD__ );
1405 # We shall not saveToCache before the commit since otherwise
1406 # in case of a rollback there is an usable file from memcached
1407 # which in fact doesn't really exist (bug 24978)
1411 # Invalidate the cache for the description page
1412 $descTitle->invalidateCache();
1413 $descTitle->purgeSquid();
1415 # New file; create the description page.
1416 # There's already a log entry, so don't make a second RC entry
1417 # Squid and file cache for the description page are purged by doEditContent.
1419 $status = $wikiPage->doEditContent(
1427 $dbw->begin( __METHOD__ );
1429 $logEntry->publish( $logId );
1430 if ( isset( $status->value[
'revision'] ) ) {
1431 $dbw->update(
'logging',
1432 array(
'log_page' => $status->value[
'revision']->getPage() ),
1433 array(
'log_id' => $logId ),
1437 $dbw->commit( __METHOD__ );
1444 # Delete old thumbnails
1449 # Remove the old file from the squid cache
1453 # Hooks, hooks, the magic of hooks...
1455 wfRunHooks(
'FileUpload',
array( $this, $reupload, $descTitle->exists() ) );
1458 # Invalidate cache for all pages using this file
1460 $update->doUpdate();
1505 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1512 $archiveRel =
'archive/' . $this->
getHashPath() . $archiveName;
1514 $status = $this->repo->publish( $srcPath, $dstRel, $archiveRel,
$flags,
$options );
1516 if ( $status->value ==
'new' ) {
1517 $status->value =
'';
1519 $status->value = $archiveName;
1544 function move( $target ) {
1545 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1549 wfDebugLog(
'imagemove',
"Got request to move {$this->name} to " . $target->getText() );
1553 $batch->addCurrent();
1554 $archiveNames =
$batch->addOlds();
1555 $status =
$batch->execute();
1558 wfDebugLog(
'imagemove',
"Finished moving {$this->name}" );
1565 $this->
getRepo()->getMasterDB()->onTransactionIdle(
1566 function () use ( $oldTitleFile, $newTitleFile, $archiveNames ) {
1567 $oldTitleFile->purgeEverything();
1568 foreach ( $archiveNames
as $archiveName ) {
1569 $oldTitleFile->purgeOldThumbnails( $archiveName );
1571 $newTitleFile->purgeEverything();
1575 if ( $status->isOK() ) {
1577 $this->
title = $target;
1579 unset( $this->
name );
1580 unset( $this->hashPath );
1598 function delete( $reason, $suppress =
false ) {
1599 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1606 $batch->addCurrent();
1607 # Get old version relative paths
1608 $archiveNames =
$batch->addOlds();
1609 $status =
$batch->execute();
1612 if ( $status->isOK() ) {
1619 $this->
getRepo()->getMasterDB()->onTransactionIdle(
1620 function () use (
$file, $archiveNames ) {
1623 $file->purgeEverything();
1624 foreach ( $archiveNames
as $archiveName ) {
1625 $file->purgeOldThumbnails( $archiveName );
1628 if ( $wgUseSquid ) {
1630 $purgeUrls =
array();
1631 foreach ( $archiveNames
as $archiveName ) {
1632 $purgeUrls[] =
$file->getArchiveUrl( $archiveName );
1656 function deleteOld( $archiveName, $reason, $suppress =
false ) {
1658 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1665 $batch->addOld( $archiveName );
1666 $status =
$batch->execute();
1670 if ( $status->isOK() ) {
1675 if ( $wgUseSquid ) {
1694 function restore( $versions =
array(), $unsuppress =
false ) {
1695 if ( $this->
getRepo()->getReadOnlyReason() !==
false ) {
1705 $batch->addIds( $versions );
1707 $status =
$batch->execute();
1708 if ( $status->isGood() ) {
1709 $cleanupStatus =
$batch->cleanup();
1710 $cleanupStatus->successCount = 0;
1711 $cleanupStatus->failCount = 0;
1712 $status->merge( $cleanupStatus );
1729 return $this->
title->getLocalURL();
1745 $content = $revision->getContent();
1749 $pout = $content->getParserOutput( $this->
title,
null,
new ParserOptions(
null, $lang ) );
1751 return $pout->getText();
1761 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_COMMENT ) ) {
1763 } elseif ( $audience == self::FOR_THIS_USER
1787 if ( $this->sha1 ==
'' && $this->fileExists ) {
1790 $this->sha1 = $this->repo->getFileSha1( $this->
getPath() );
1791 if ( !
wfReadOnly() && strval( $this->sha1 ) !=
'' ) {
1792 $dbw = $this->repo->getMasterDB();
1793 $dbw->update(
'image',
1794 array(
'img_sha1' => $this->sha1 ),
1813 return $this->extraDataLoaded
1824 $dbw = $this->repo->getMasterDB();
1826 if ( !$this->locked ) {
1827 if ( !$dbw->trxLevel() ) {
1828 $dbw->begin( __METHOD__ );
1829 $this->lockedOwnTrx =
true;
1836 if ( !
$cache->lock( $key, 5 ) ) {
1837 throw new MWException(
"Could not acquire lock for '{$this->getName()}.'" );
1839 $dbw->onTransactionIdle(
function () use (
$cache, $key ) {
1844 return $dbw->selectField(
'image',
'1',
1853 if ( $this->locked ) {
1855 if ( !$this->locked && $this->lockedOwnTrx ) {
1856 $dbw = $this->repo->getMasterDB();
1857 $dbw->commit( __METHOD__ );
1858 $this->lockedOwnTrx =
false;
1867 $this->locked =
false;
1868 $dbw = $this->repo->getMasterDB();
1869 $dbw->rollback( __METHOD__ );
1870 $this->lockedOwnTrx =
false;
1889 # ------------------------------------------------------------------------------
1926 $this->status =
$file->repo->newGood();
1930 $this->srcRels[
'.'] = $this->
file->getRel();
1936 function addOld( $oldName ) {
1937 $this->srcRels[$oldName] = $this->
file->getArchiveRel( $oldName );
1938 $this->archiveUrls[] = $this->
file->getArchiveUrl( $oldName );
1946 $archiveNames =
array();
1948 $dbw = $this->
file->repo->getMasterDB();
1949 $result = $dbw->select(
'oldimage',
1951 array(
'oi_name' => $this->
file->getName() ),
1956 $this->
addOld( $row->oi_archive_name );
1957 $archiveNames[] = $row->oi_archive_name;
1960 return $archiveNames;
1967 if ( !isset( $this->srcRels[
'.'] ) ) {
1969 $deleteCurrent =
false;
1972 unset( $oldRels[
'.'] );
1973 $deleteCurrent =
true;
1976 return array( $oldRels, $deleteCurrent );
1986 if ( $deleteCurrent ) {
1990 if ( count( $oldRels ) ) {
1991 $dbw = $this->
file->repo->getMasterDB();
1992 $res = $dbw->select(
1994 array(
'oi_archive_name',
'oi_sha1' ),
1995 array(
'oi_archive_name' => array_keys( $oldRels ) ),
1999 foreach (
$res as $row ) {
2000 if ( rtrim( $row->oi_sha1,
"\0" ) ===
'' ) {
2002 $oldUrl = $this->
file->getArchiveVirtualUrl( $row->oi_archive_name );
2003 $props = $this->
file->repo->getFileProps( $oldUrl );
2005 if ( $props[
'fileExists'] ) {
2007 $dbw->update(
'oldimage',
2008 array(
'oi_sha1' => $props[
'sha1'] ),
2009 array(
'oi_name' => $this->
file->getName(),
'oi_archive_name' => $row->oi_archive_name ),
2011 $hashes[$row->oi_archive_name] = $props[
'sha1'];
2013 $hashes[$row->oi_archive_name] =
false;
2016 $hashes[$row->oi_archive_name] = $row->oi_sha1;
2021 $missing = array_diff_key( $this->srcRels,
$hashes );
2023 foreach ( $missing
as $name => $rel ) {
2024 $this->status->error(
'filedelete-old-unregistered',
$name );
2029 $this->status->error(
'filedelete-missing', $this->srcRels[
$name] );
2040 $dbw = $this->
file->repo->getMasterDB();
2041 $encTimestamp = $dbw->addQuotes( $dbw->timestamp() );
2042 $encUserId = $dbw->addQuotes(
$wgUser->getId() );
2043 $encReason = $dbw->addQuotes( $this->reason );
2044 $encGroup = $dbw->addQuotes(
'deleted' );
2045 $ext = $this->
file->getExtension();
2046 $dotExt =
$ext ===
'' ?
'' :
".$ext";
2047 $encExt = $dbw->addQuotes( $dotExt );
2051 if ( $this->suppress ) {
2059 $bitfield =
'oi_deleted';
2062 if ( $deleteCurrent ) {
2063 $concat = $dbw->buildConcat(
array(
"img_sha1", $encExt ) );
2064 $where =
array(
'img_name' => $this->
file->getName() );
2065 $dbw->insertSelect(
'filearchive',
'image',
2067 'fa_storage_group' => $encGroup,
2068 'fa_storage_key' =>
"CASE WHEN img_sha1='' THEN '' ELSE $concat END",
2069 'fa_deleted_user' => $encUserId,
2070 'fa_deleted_timestamp' => $encTimestamp,
2071 'fa_deleted_reason' => $encReason,
2072 'fa_deleted' => $this->suppress ? $bitfield : 0,
2074 'fa_name' =>
'img_name',
2075 'fa_archive_name' =>
'NULL',
2076 'fa_size' =>
'img_size',
2077 'fa_width' =>
'img_width',
2078 'fa_height' =>
'img_height',
2079 'fa_metadata' =>
'img_metadata',
2080 'fa_bits' =>
'img_bits',
2081 'fa_media_type' =>
'img_media_type',
2082 'fa_major_mime' =>
'img_major_mime',
2083 'fa_minor_mime' =>
'img_minor_mime',
2084 'fa_description' =>
'img_description',
2085 'fa_user' =>
'img_user',
2086 'fa_user_text' =>
'img_user_text',
2087 'fa_timestamp' =>
'img_timestamp',
2088 'fa_sha1' =>
'img_sha1',
2089 ), $where, __METHOD__ );
2092 if ( count( $oldRels ) ) {
2093 $concat = $dbw->buildConcat(
array(
"oi_sha1", $encExt ) );
2095 'oi_name' => $this->
file->getName(),
2096 'oi_archive_name' => array_keys( $oldRels ) );
2097 $dbw->insertSelect(
'filearchive',
'oldimage',
2099 'fa_storage_group' => $encGroup,
2100 'fa_storage_key' =>
"CASE WHEN oi_sha1='' THEN '' ELSE $concat END",
2101 'fa_deleted_user' => $encUserId,
2102 'fa_deleted_timestamp' => $encTimestamp,
2103 'fa_deleted_reason' => $encReason,
2104 'fa_deleted' => $this->suppress ? $bitfield :
'oi_deleted',
2106 'fa_name' =>
'oi_name',
2107 'fa_archive_name' =>
'oi_archive_name',
2108 'fa_size' =>
'oi_size',
2109 'fa_width' =>
'oi_width',
2110 'fa_height' =>
'oi_height',
2111 'fa_metadata' =>
'oi_metadata',
2112 'fa_bits' =>
'oi_bits',
2113 'fa_media_type' =>
'oi_media_type',
2114 'fa_major_mime' =>
'oi_major_mime',
2115 'fa_minor_mime' =>
'oi_minor_mime',
2116 'fa_description' =>
'oi_description',
2117 'fa_user' =>
'oi_user',
2118 'fa_user_text' =>
'oi_user_text',
2119 'fa_timestamp' =>
'oi_timestamp',
2120 'fa_sha1' =>
'oi_sha1',
2121 ), $where, __METHOD__ );
2126 $dbw = $this->
file->repo->getMasterDB();
2129 if ( count( $oldRels ) ) {
2130 $dbw->delete(
'oldimage',
2132 'oi_name' => $this->
file->getName(),
2133 'oi_archive_name' => array_keys( $oldRels )
2137 if ( $deleteCurrent ) {
2138 $dbw->delete(
'image',
array(
'img_name' => $this->
file->getName() ), __METHOD__ );
2149 $this->
file->lock();
2151 $privateFiles =
array();
2153 $dbw = $this->
file->repo->getMasterDB();
2155 if ( !empty( $oldRels ) ) {
2156 $res = $dbw->select(
'oldimage',
2157 array(
'oi_archive_name' ),
2158 array(
'oi_name' => $this->
file->getName(),
2159 'oi_archive_name' => array_keys( $oldRels ),
2163 foreach (
$res as $row ) {
2164 $privateFiles[$row->oi_archive_name] = 1;
2169 $this->deletionBatch =
array();
2170 $ext = $this->
file->getExtension();
2171 $dotExt =
$ext ===
'' ?
'' :
".$ext";
2173 foreach ( $this->srcRels
as $name => $srcRel ) {
2178 $key =
$hash . $dotExt;
2179 $dstRel = $this->
file->repo->getDeletedHashPath( $key ) . $key;
2180 $this->deletionBatch[
$name] =
array( $srcRel, $dstRel );
2196 $status = $this->
file->repo->deleteBatch( $this->deletionBatch );
2199 $this->status->merge(
$status );
2202 if ( !$this->status->isOK() ) {
2206 $this->
file->unlockAndRollback();
2216 $this->
file->unlock();
2231 list( $src, ) = $batchItem;
2232 $files[$src] = $this->
file->repo->getVirtualUrl(
'public' ) .
'/' . rawurlencode( $src );
2237 foreach ( $batch
as $batchItem ) {
2238 if (
$result[$batchItem[0]] ) {
2239 $newBatch[] = $batchItem;
2247 # ------------------------------------------------------------------------------
2275 $this->cleanupBatch = $this->ids =
array();
2276 $this->ids =
array();
2283 function addId( $fa_id ) {
2284 $this->ids[] = $fa_id;
2291 $this->ids = array_merge( $this->ids,
$ids );
2312 if ( !$this->all && !$this->ids ) {
2314 return $this->
file->repo->newGood();
2317 $exists = $this->
file->lock();
2318 $dbw = $this->
file->repo->getMasterDB();
2319 $status = $this->
file->repo->newGood();
2323 $conditions =
array(
'fa_name' => $this->
file->getName() );
2325 if ( !$this->all ) {
2334 array(
'ORDER BY' =>
'fa_timestamp DESC' )
2337 $idsPresent =
array();
2338 $storeBatch =
array();
2339 $insertBatch =
array();
2340 $insertCurrent =
false;
2341 $deleteIds =
array();
2343 $archiveNames =
array();
2346 $idsPresent[] = $row->fa_id;
2348 if ( $row->fa_name != $this->file->getName() ) {
2349 $status->error(
'undelete-filename-mismatch',
$wgLang->timeanddate( $row->fa_timestamp ) );
2350 $status->failCount++;
2354 if ( $row->fa_storage_key ==
'' ) {
2356 $status->error(
'undelete-bad-store-key',
$wgLang->timeanddate( $row->fa_timestamp ) );
2357 $status->failCount++;
2361 $deletedRel = $this->
file->repo->getDeletedHashPath( $row->fa_storage_key ) .
2362 $row->fa_storage_key;
2363 $deletedUrl = $this->
file->repo->getVirtualUrl() .
'/deleted/' . $deletedRel;
2365 if ( isset( $row->fa_sha1 ) ) {
2366 $sha1 = $row->fa_sha1;
2373 if ( strlen( $sha1 ) == 32 && $sha1[0] ==
'0' ) {
2374 $sha1 = substr( $sha1, 1 );
2377 if ( is_null( $row->fa_major_mime ) || $row->fa_major_mime ==
'unknown'
2378 || is_null( $row->fa_minor_mime ) || $row->fa_minor_mime ==
'unknown'
2379 || is_null( $row->fa_media_type ) || $row->fa_media_type ==
'UNKNOWN'
2380 || is_null( $row->fa_metadata )
2387 'minor_mime' => $row->fa_minor_mime,
2388 'major_mime' => $row->fa_major_mime,
2389 'media_type' => $row->fa_media_type,
2390 'metadata' => $row->fa_metadata
2394 if ( $first && !$exists ) {
2396 $destRel = $this->
file->getRel();
2397 $insertCurrent =
array(
2398 'img_name' => $row->fa_name,
2399 'img_size' => $row->fa_size,
2400 'img_width' => $row->fa_width,
2401 'img_height' => $row->fa_height,
2402 'img_metadata' => $props[
'metadata'],
2403 'img_bits' => $row->fa_bits,
2404 'img_media_type' => $props[
'media_type'],
2405 'img_major_mime' => $props[
'major_mime'],
2406 'img_minor_mime' => $props[
'minor_mime'],
2407 'img_description' => $row->fa_description,
2408 'img_user' => $row->fa_user,
2409 'img_user_text' => $row->fa_user_text,
2410 'img_timestamp' => $row->fa_timestamp,
2415 if ( !$this->unsuppress && $row->fa_deleted ) {
2416 $storeBatch[] =
array( $deletedUrl,
'public', $destRel );
2417 $this->cleanupBatch[] = $row->fa_storage_key;
2420 $archiveName = $row->fa_archive_name;
2422 if ( $archiveName ==
'' ) {
2431 }
while ( isset( $archiveNames[$archiveName] ) );
2434 $archiveNames[$archiveName] =
true;
2435 $destRel = $this->
file->getArchiveRel( $archiveName );
2436 $insertBatch[] =
array(
2437 'oi_name' => $row->fa_name,
2438 'oi_archive_name' => $archiveName,
2439 'oi_size' => $row->fa_size,
2440 'oi_width' => $row->fa_width,
2441 'oi_height' => $row->fa_height,
2442 'oi_bits' => $row->fa_bits,
2443 'oi_description' => $row->fa_description,
2444 'oi_user' => $row->fa_user,
2445 'oi_user_text' => $row->fa_user_text,
2446 'oi_timestamp' => $row->fa_timestamp,
2447 'oi_metadata' => $props[
'metadata'],
2448 'oi_media_type' => $props[
'media_type'],
2449 'oi_major_mime' => $props[
'major_mime'],
2450 'oi_minor_mime' => $props[
'minor_mime'],
2451 'oi_deleted' => $this->unsuppress ? 0 : $row->fa_deleted,
2452 'oi_sha1' => $sha1 );
2455 $deleteIds[] = $row->fa_id;
2459 $status->successCount++;
2461 $storeBatch[] =
array( $deletedUrl,
'public', $destRel );
2462 $this->cleanupBatch[] = $row->fa_storage_key;
2471 $missingIds = array_diff( $this->ids, $idsPresent );
2473 foreach ( $missingIds
as $id ) {
2474 $status->error(
'undelete-missing-filearchive', $id );
2483 $status->merge( $storeStatus );
2485 if ( !$status->isGood() ) {
2489 $status->ok =
false;
2490 $this->
file->unlock();
2501 if ( $insertCurrent ) {
2502 $dbw->insert(
'image', $insertCurrent, __METHOD__ );
2505 if ( $insertBatch ) {
2506 $dbw->insert(
'oldimage', $insertBatch, __METHOD__ );
2510 $dbw->delete(
'filearchive',
2511 array(
'fa_id' => $deleteIds ),
2516 if ( $status->successCount > 0 || !$storeBatch ) {
2518 wfDebug( __METHOD__ .
" restored {$status->successCount} items, creating a new current\n" );
2522 $this->
file->purgeEverything();
2524 wfDebug( __METHOD__ .
" restored {$status->successCount} as archived versions\n" );
2526 $this->
file->purgeHistory();
2530 $this->
file->unlock();
2542 foreach ( $triplets
as $file ) {
2548 foreach ( $triplets
as $file ) {
2554 return $filteredTriplets;
2564 $repo = $this->
file->repo;
2567 $files[
$file] = $repo->getVirtualUrl(
'deleted' ) .
'/' .
2568 rawurlencode( $repo->getDeletedHashPath(
$file ) .
$file );
2575 $newBatch[] =
$file;
2588 if ( !$this->cleanupBatch ) {
2589 return $this->
file->repo->newGood();
2594 $status = $this->
file->repo->cleanupDeletedBatch( $this->cleanupBatch );
2621 # ------------------------------------------------------------------------------
2652 $this->oldHash = $this->
file->repo->getHashPath( $this->
file->getName() );
2653 $this->newHash = $this->
file->repo->getHashPath( $this->target->getDBkey() );
2654 $this->oldName = $this->
file->getName();
2655 $this->newName = $this->
file->repo->getNameFromTitle( $this->target );
2656 $this->oldRel = $this->oldHash . $this->oldName;
2657 $this->newRel = $this->newHash . $this->newName;
2665 $this->cur =
array( $this->oldRel, $this->newRel );
2673 $archiveBase =
'archive';
2674 $this->olds =
array();
2675 $this->oldCount = 0;
2676 $archiveNames =
array();
2678 $result = $this->db->select(
'oldimage',
2679 array(
'oi_archive_name',
'oi_deleted' ),
2680 array(
'oi_name' => $this->oldName ),
2685 $archiveNames[] = $row->oi_archive_name;
2686 $oldName = $row->oi_archive_name;
2687 $bits = explode(
'!', $oldName, 2 );
2689 if ( count( $bits ) != 2 ) {
2690 wfDebug(
"Old file name missing !: '$oldName' \n" );
2696 if ( $this->oldName != $filename ) {
2697 wfDebug(
"Old file name doesn't match: '$oldName' \n" );
2708 $this->olds[] =
array(
2709 "{$archiveBase}/{$this->oldHash}{$oldName}",
2710 "{$archiveBase}/{$this->newHash}{$timestamp}!{$this->newName}"
2714 return $archiveNames;
2722 $repo = $this->
file->repo;
2723 $status = $repo->newGood();
2729 $this->
file->lock();
2737 if ( !$statusDb->isGood() ) {
2738 $this->
file->unlockAndRollback();
2739 $statusDb->ok =
false;
2743 wfDebugLog(
'imagemove',
"Renamed {$this->file->getName()} in database: " .
2744 "{$statusDb->successCount} successes, {$statusDb->failCount} failures" );
2750 wfDebugLog(
'imagemove',
"Moved files for {$this->file->getName()}: " .
2751 "{$statusMove->successCount} successes, {$statusMove->failCount} failures" );
2752 if ( !$statusMove->isGood() ) {
2755 $this->
file->unlockAndRollback();
2756 wfDebugLog(
'imagemove',
"Error in moving files: " . $statusMove->getWikiText() );
2757 $statusMove->ok =
false;
2761 $destFile->unlock();
2762 $this->
file->unlock();
2767 $status->merge( $statusDb );
2768 $status->merge( $statusMove );
2780 $repo = $this->
file->repo;
2781 $status = $repo->newGood();
2787 array(
'img_name' => $this->newName ),
2788 array(
'img_name' => $this->oldName ),
2792 if ( $dbw->affectedRows() ) {
2793 $status->successCount++;
2795 $status->failCount++;
2796 $status->fatal(
'imageinvalidfilename' );
2805 'oi_name' => $this->newName,
2806 'oi_archive_name = ' . $dbw->strreplace(
'oi_archive_name',
2807 $dbw->addQuotes( $this->oldName ), $dbw->addQuotes( $this->newName ) ),
2809 array(
'oi_name' => $this->oldName ),
2813 $affected = $dbw->affectedRows();
2815 $status->successCount += $affected;
2819 $status->failCount += max( 0,
$total - $affected );
2820 if ( $status->failCount ) {
2821 $status->error(
'imageinvalidfilename' );
2832 $moves = array_merge(
array( $this->cur ), $this->olds );
2833 $triplets =
array();
2835 foreach ( $moves
as $move ) {
2837 $srcUrl = $this->
file->repo->getVirtualUrl() .
'/public/' . rawurlencode( $move[0] );
2838 $triplets[] =
array( $srcUrl,
'public', $move[1] );
2841 "Generated move triplet for {$this->file->getName()}: {$srcUrl} :: public :: {$move[1]}"
2856 foreach ( $triplets
as $file ) {
2861 $filteredTriplets =
array();
2863 foreach ( $triplets
as $file ) {
2865 $filteredTriplets[] =
$file;
2867 wfDebugLog(
'imagemove',
"File {$file[0]} does not exist" );
2871 return $filteredTriplets;
2881 foreach ( $triplets
as $triplet ) {
2883 $pairs[] =
array( $triplet[1], $triplet[2] );
2886 $this->
file->repo->cleanupBatch( $pairs );
2896 foreach ( $triplets
as $triplet ) {
string $media_type
MEDIATYPE_xxx (bitmap, drawing, audio...) *.
Set options of the Parser.
bool $fileExists
Does the file exist on disk? (loadFromXxx) *.
getPath()
Return the storage path to the file.
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
maybeUpgradeRow()
Upgrade a row if it needs it.
Helper class for file undeletion.
array $deletionBatch
Items to be processed in the deletion 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. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag '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 '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. '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 '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 '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 wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() '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 User::isValidEmailAddr(), 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. '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 '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) '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:Associative array mapping language codes to prefixed links of the form "language:title". & $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. 'LinkBegin':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
unprefixRow( $row, $prefix='img_')
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
deleteOld( $archiveName, $reason, $suppress=false)
Delete an old version of the 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.
__construct( $title, $repo)
Constructor.
unlock()
Decrement the lock reference count.
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
isMultipage()
Returns 'true' if this file is a type which supports multiple pages, e.g.
static newNullRevision( $dbw, $pageId, $summary, $minor)
Create a new null-revision for insertion into a page's history.
getUser( $type='text')
Returns ID or name of user who uploaded the file.
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
unlockAndRollback()
Roll back the DB transaction and mark the image unlocked.
purgeCache( $options=array())
Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid.
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.
static getPropsFromPath( $path, $ext=true)
Get an associative array containing information about a file in the local filesystem.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
bool $missing
True if file is not present in file system.
Helper class for file deletion.
execute()
Run the transaction, except the cleanup batch.
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.
File backend exception for checked exceptions (e.g.
bool $upgraded
Whether the row was upgraded on load *.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfProfileIn( $functionname)
Begin profiling of a function.
getCacheFields( $prefix='img_')
bool $all
Add all revisions of the file *.
int $user
User ID of uploader *.
__construct(File $file, Title $target)
execute()
Run the transaction.
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.
bool $dataLoaded
Whether or not core data has been loaded from the database (loadFromXxx) *.
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.
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.
saveToCache()
Save the file metadata to memcached.
purgeThumbnails( $options=array())
Delete cached transformed files for the current version only.
int $historyRes
Result of the query for the file's history (nextHistoryLine) *.
getThumbnails( $archiveName=false)
getHandler 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 '...
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 and the content language as $wgContLang
__construct(File $file, $unsuppress=false)
it s the revision text itself In either if gzip is the revision text is gzipped $flags
string $minor_mime
Minor mime type *.
isDeleted( $field)
Is this file a "deleted" file in a private archive? STUB.
static getHashFromKey( $key)
Gets the SHA1 hash from a storage key.
isGood()
Returns whether the operation completed and didn't have any error or warnings.
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
update( $table, $values, $conds, $fname=__METHOD__, $options=array())
UPDATE wrapper.
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
cleanupFailedBatch( $storeStatus, $storeBatch)
Cleanup a failed batch.
Implements some public methods and some protected utility functions which are required by multiple ch...
loadExtraFromDB()
Load lazy file metadata from the DB.
wfGetMainCache()
Get the main cache object.
static newFromRow( $row, $repo)
Create a LocalFile from a title Do not call this except from inside a repo class.
purgeMetadataCache()
Refresh metadata in memcached, but don't touch thumbnails or squid.
getThumbPath( $suffix=false)
Get the path of the thumbnail directory, or a particular file if $suffix is specified.
wfIncrStats( $key, $count=1)
Increment a statistics counter.
static isStoragePath( $path)
Check if a given path is a "mwstore://" path.
const CACHE_FIELD_MAX_LEN
publishTo( $srcPath, $dstRel, $flags=0, array $options=array())
Move or copy a file to a specified location.
loadFromRow( $row, $prefix='img_')
Load file metadata from a DB result row.
const MW_FILE_VERSION
Bump this number when serialized cache records may be incompatible.
__destruct()
Clean up any dangling locks.
int $deleted
Bitfield akin to rev_deleted *.
static purge( $urlArr)
Purges a list of Squids defined in $wgSquidServers.
static addUpdate(DeferrableUpdate $update)
Add an update to the deferred list.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
recordUpload2( $oldver, $comment, $pageText, $props=false, $timestamp=false, $user=null)
Record a file upload in the upload log and the image table.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
bool $suppress
Wether to suppress all suppressable fields when deleting *.
migrateThumbFile( $thumbName)
getTransformScript inherited
__construct(File $file, $reason='', $suppress=false)
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
static factory(array $deltas)
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...
addAll()
Add all revisions of the file.
string $mime
MIME type, determined by MimeMagic::guessMimeType *.
bool $unsuppress
Wether to remove all settings for suppressed fields *.
setProps( $info)
Set properties in this object to be equal to those given in the associative array $info.
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.
processing should stop and the error should be shown to the user * false
upload( $srcPath, $comment, $pageText, $flags=0, $props=false, $timestamp=false, $user=null)
getHashPath inherited
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)
purgeHistory()
Purge the shared history (OldLocalFile) cache.
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
bool $extraDataLoaded
Whether or not lazy-loaded data has been loaded from the database *.
int $size
Size in bytes (loadFromXxx) *.
restore( $versions=array(), $unsuppress=false)
Restore all or specified deleted revisions to the given file.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
static newFromTitle( $title, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given title.
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Class to invalidate the HTML cache of all the pages linking to a given title.
purgeDescription()
Purge the file description page, but don't go after pages using the file.
Allows to change the fields on the form that will be generated $name
loadFromDB()
Load file metadata from the DB.
lock()
Start a transaction and lock the image for update Increments a reference counter if the lock is alrea...
assertTitleDefined()
Assert that $this->title is set to a Title.
int $historyLine
Number of line to return by nextHistoryLine() (constructor) *.
getMoveTriplets()
Generate triplets for FileRepo::storeBatch().
Database abstraction object.
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.
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 *.
static getInitialPageText( $comment='', $license='', $copyStatus='', $source='')
Get the initial image page text based on a comment and optional file status information.
int $height
image height *
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.
string $timestamp
Upload timestamp *.
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
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.
if(PHP_SAPI !='cli') $file
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.
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
addIds( $ids)
Add a whole lot of files by ID.
loadFromFile()
Load metadata from the file itself.
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
execute()
Perform the move.
if(count( $args)==0) $dir
getDescriptionText( $lang=null)
Get the HTML text of the description page This is not used by ImagePage for local files,...
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
resetHistory()
Reset the history pointer to the first element of the history.
removeNonexistentFiles( $triplets)
Removes non-existent files from move batch.
cleanup()
Delete unused files in the deleted zone.
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.
Helper class for file movement.
if(PHP_SAPI !='cli') $source
Class for creating log entries manually, for example to inject them into the database.
Generic operation result class for FileRepo-related operations.
Special handling for file pages.
string $name
The name of a file from its title object *.
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
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 *.
getHandler()
Get a MediaHandler instance for this file.
getHeight( $page=1)
Return the height of the image.
isMissing()
splitMime inherited
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,...
wfLocalFile( $title)
Get an object referring to a locally registered file.
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 FileRepoStatus indicating how many rows where updated.
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
exists()
canRender inherited
getThumbnails()
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.
publish( $srcPath, $flags=0, array $options=array())
Move or copy a file to its public location.
loadFromCache()
Try to load file metadata from memcached.
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.