Go to the documentation of this file.
36 public function run() {
39 $transformParams = $this->params[
'transformParams'];
41 $file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
42 ->newFile( $this->title );
43 $file->load( File::READ_LATEST );
49 if ( !$thumb || $thumb->isError() ) {
51 $this->
setLastError( __METHOD__ .
': thumbnail couln\'t be generated:' .
54 $this->
setLastError( __METHOD__ .
': thumbnail couln\'t be generated' );
62 $this->
setLastError( __METHOD__ .
': unknown thumbnail render method ' .
67 $this->
setLastError( __METHOD__ .
': file doesn\'t exist' );
80 $handler =
$file->getHandler();
82 $this->
setLastError( __METHOD__ .
': could not get handler' );
84 } elseif ( !$handler->normaliseParams(
$file, $transformParams ) ) {
85 $this->
setLastError( __METHOD__ .
': failed to normalize' );
88 $thumbName =
$file->thumbName( $transformParams );
89 $thumbUrl =
$file->getThumbUrl( $thumbName );
91 if ( $thumbUrl ===
null ) {
92 $this->
setLastError( __METHOD__ .
': could not get thumb URL' );
99 if ( !isset( $parsedUrl[
'path'] ) || $parsedUrl[
'path'] ===
'' ) {
100 $this->
setLastError( __METHOD__ .
": invalid thumb URL: $thumbUrl" );
107 wfDebug( __METHOD__ .
": hitting url {$thumbUrl}\n" );
111 $request = MediaWikiServices::getInstance()->getHttpRequestFactory()->create(
113 [
'method' =>
'HEAD',
'followRedirects' =>
true,
'timeout' => 1 ],
121 $status = $request->execute();
122 $statusCode = $request->getStatus();
123 wfDebug( __METHOD__ .
": received status {$statusCode}\n" );
127 if ( $statusCode === 200 || $statusCode === 301 || $statusCode === 302 || $statusCode === 400 ) {
129 } elseif ( $statusCode ) {
130 $this->
setLastError( __METHOD__ .
": incorrect HTTP status $statusCode when hitting $thumbUrl" );
131 } elseif ( $status->hasMessage(
'http-timed-out' ) ) {
136 $this->
setLastError( __METHOD__ .
': HTTP request failure: '
137 .
Status::wrap( $status )->getWikiText(
null,
null,
'en' ) );
hitThumbUrl(LocalFile $file, $transformParams)
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
array $params
Array of job parameters.
Class to both describe a background job and handle jobs.
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
static wrap( $sv)
Succinct helper method to wrap a StatusValue.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Class to represent a local file in the wiki's own database.
Job for asynchronous rendering of thumbnails.
__construct(Title $title, array $params)
$wgUploadThumbnailRenderHttpCustomHost
When using the "http" wgUploadThumbnailRenderMethod, lets one specify a custom Host HTTP header.
const RENDER_NOW
Force rendering in the current process.
Represents a title within MediaWiki.
allowRetries()
Whether to retry the job.
$wgUploadThumbnailRenderMethod
The method through which the thumbnails will be prerendered for the entries in $wgUploadThumbnailRend...
$wgUploadThumbnailRenderHttpCustomDomain
When using the "http" wgUploadThumbnailRenderMethod, lets one specify a custom domain to send the HTT...