jenkins-bot has submitted this change and it was merged.
Change subject: Move thumbnail rendering to a more appropriate spot
......................................................................
Move thumbnail rendering to a more appropriate spot
At the moment the job might start before the transaction
that creates the file's row in the DB has had a chance
to run.
Bug: T106740
Change-Id: If5b94e83d8bbcc6aebfe7193f7b580f03cbd627d
---
M includes/filerepo/file/LocalFile.php
M includes/upload/UploadBase.php
2 files changed, 29 insertions(+), 21 deletions(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index 6eed222..91d628c 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -974,6 +974,33 @@
}
/**
+ * Prerenders a configurable set of thumbnails
+ *
+ * @since 1.28
+ */
+ public function prerenderThumbnails() {
+ global $wgUploadThumbnailRenderMap;
+
+ $jobs = [];
+
+ $sizes = $wgUploadThumbnailRenderMap;
+ rsort( $sizes );
+
+ foreach ( $sizes as $size ) {
+ if ( $this->isVectorized() || $this->getWidth() > $size
) {
+ $jobs[] = new ThumbnailRenderJob(
+ $this->getTitle(),
+ [ 'transformParams' => [ 'width' =>
$size ] ]
+ );
+ }
+ }
+
+ if ( $jobs ) {
+ JobQueueGroup::singleton()->lazyPush( $jobs );
+ }
+ }
+
+ /**
* Delete a list of thumbnails visible at urls
* @param string $dir Base dir of the files.
* @param array $files Array of strings: relative filenames (to $dir)
@@ -1525,6 +1552,8 @@
# Update backlink pages
pointing to this title if created
LinksUpdate::queueRecursiveJobsForTable( $this->getTitle(), 'imagelinks' );
}
+
+ $this->prerenderThumbnails();
}
),
DeferredUpdates::PRESEND
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index 03c864a..9f534d2 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -774,27 +774,6 @@
* @since 1.25
*/
public function postProcessUpload() {
- global $wgUploadThumbnailRenderMap;
-
- $jobs = [];
-
- $sizes = $wgUploadThumbnailRenderMap;
- rsort( $sizes );
-
- $file = $this->getLocalFile();
-
- foreach ( $sizes as $size ) {
- if ( $file->isVectorized() || $file->getWidth() > $size
) {
- $jobs[] = new ThumbnailRenderJob(
- $file->getTitle(),
- [ 'transformParams' => [ 'width' =>
$size ] ]
- );
- }
- }
-
- if ( $jobs ) {
- JobQueueGroup::singleton()->push( $jobs );
- }
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/305010
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If5b94e83d8bbcc6aebfe7193f7b580f03cbd627d
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits