summaryrefslogtreecommitdiff
path: root/includes/filerepo/File.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/filerepo/File.php')
-rw-r--r--includes/filerepo/File.php76
1 files changed, 54 insertions, 22 deletions
diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php
index 523a1c09..d79a1661 100644
--- a/includes/filerepo/File.php
+++ b/includes/filerepo/File.php
@@ -529,7 +529,7 @@ abstract class File {
* @return MediaTransformOutput
*/
function transform( $params, $flags = 0 ) {
- global $wgUseSquid, $wgIgnoreImageErrors;
+ global $wgUseSquid, $wgIgnoreImageErrors, $wgThumbnailEpoch, $wgServer;
wfProfileIn( __METHOD__ );
do {
@@ -539,6 +539,12 @@ abstract class File {
break;
}
+ // Get the descriptionUrl to embed it as comment into the thumbnail. Bug 19791.
+ $descriptionUrl = $this->getDescriptionUrl();
+ if ( $descriptionUrl ) {
+ $params['descriptionUrl'] = $wgServer . $descriptionUrl;
+ }
+
$script = $this->getTransformScript();
if ( $script && !($flags & self::RENDER_NOW) ) {
// Use a script to transform on client request, if possible
@@ -561,9 +567,14 @@ abstract class File {
wfDebug( __METHOD__.": Doing stat for $thumbPath\n" );
$this->migrateThumbFile( $thumbName );
- if ( file_exists( $thumbPath ) ) {
- $thumb = $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
- break;
+ if ( file_exists( $thumbPath )) {
+ $thumbTime = filemtime( $thumbPath );
+ if ( $thumbTime !== FALSE &&
+ gmdate( 'YmdHis', $thumbTime ) >= $wgThumbnailEpoch ) {
+
+ $thumb = $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
+ break;
+ }
}
$thumb = $this->handler->doTransform( $this, $thumbPath, $thumbUrl, $params );
@@ -746,15 +757,6 @@ abstract class File {
return $path;
}
- /** Get relative path for a thumbnail file */
- function getThumbRel( $suffix = false ) {
- $path = 'thumb/' . $this->getRel();
- if ( $suffix !== false ) {
- $path .= '/' . $suffix;
- }
- return $path;
- }
-
/** Get the path of the archive directory, or a particular file if $suffix is specified */
function getArchivePath( $suffix = false ) {
return $this->repo->getZonePath('public') . '/' . $this->getArchiveRel( $suffix );
@@ -762,7 +764,11 @@ abstract class File {
/** Get the path of the thumbnail directory, or a particular file if $suffix is specified */
function getThumbPath( $suffix = false ) {
- return $this->repo->getZonePath('public') . '/' . $this->getThumbRel( $suffix );
+ $path = $this->repo->getZonePath('thumb') . '/' . $this->getRel();
+ if ( $suffix !== false ) {
+ $path .= '/' . $suffix;
+ }
+ return $path;
}
/** Get the URL of the archive directory, or a particular file if $suffix is specified */
@@ -778,7 +784,7 @@ abstract class File {
/** Get the URL of the thumbnail directory, or a particular file if $suffix is specified */
function getThumbUrl( $suffix = false ) {
- $path = $this->repo->getZoneUrl('public') . '/thumb/' . $this->getUrlRel();
+ $path = $this->repo->getZoneUrl('thumb') . '/' . $this->getUrlRel();
if ( $suffix !== false ) {
$path .= '/' . rawurlencode( $suffix );
}
@@ -798,7 +804,7 @@ abstract class File {
/** Get the virtual URL for a thumbnail file or directory */
function getThumbVirtualUrl( $suffix = false ) {
- $path = $this->repo->getVirtualUrl() . '/public/thumb/' . $this->getUrlRel();
+ $path = $this->repo->getVirtualUrl() . '/thumb/' . $this->getUrlRel();
if ( $suffix !== false ) {
$path .= '/' . rawurlencode( $suffix );
}
@@ -943,6 +949,14 @@ abstract class File {
function isDeleted( $field ) {
return false;
}
+
+ /**
+ * Return the deletion bitfield
+ * STUB
+ */
+ function getVisibility() {
+ return 0;
+ }
/**
* Was this file ever deleted from the wiki?
@@ -1007,8 +1021,9 @@ abstract class File {
}
/**
- * Returns 'true' if this image is a multipage document, e.g. a DJVU
- * document.
+ * Returns 'true' if this file is a type which supports multiple pages,
+ * e.g. DJVU or PDF. Note that this may be true even if the file in
+ * question only has a single page.
*
* @return Bool
*/
@@ -1069,15 +1084,15 @@ abstract class File {
* Get the HTML text of the description page, if available
*/
function getDescriptionText() {
- global $wgMemc, $wgContLang;
+ global $wgMemc, $wgLang;
if ( !$this->repo->fetchDescription ) {
return false;
}
- $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $wgContLang->getCode() );
+ $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $wgLang->getCode() );
if ( $renderUrl ) {
if ( $this->repo->descriptionCacheExpiry > 0 ) {
wfDebug("Attempting to get the description from cache...");
- $key = wfMemcKey( 'RemoteFileDescription', 'url', $wgContLang->getCode(),
+ $key = $this->repo->getLocalCacheKey( 'RemoteFileDescription', 'url', $wgLang->getCode(),
$this->getName() );
$obj = $wgMemc->get($key);
if ($obj) {
@@ -1125,6 +1140,19 @@ abstract class File {
}
/**
+ * Get the deletion archive key, <sha1>.<ext>
+ */
+ function getStorageKey() {
+ $hash = $this->getSha1();
+ if ( !$hash ) {
+ return false;
+ }
+ $ext = $this->getExtension();
+ $dotExt = $ext === '' ? '' : ".$ext";
+ return $hash . $dotExt;
+ }
+
+ /**
* Determine if the current user is allowed to view a particular
* field of this file, if it's marked as deleted.
* STUB
@@ -1173,7 +1201,7 @@ abstract class File {
wfDebug(__METHOD__.": $path loaded, {$info['size']} bytes, {$info['mime']}.\n");
} else {
- $info['mime'] = NULL;
+ $info['mime'] = null;
$info['media_type'] = MEDIATYPE_UNKNOWN;
$info['metadata'] = '';
$info['sha1'] = '';
@@ -1259,6 +1287,10 @@ abstract class File {
function redirectedFrom( $from ) {
$this->redirected = $from;
}
+
+ function isMissing() {
+ return false;
+ }
}
/**
* Aliases for backwards compatibility with 1.6