Gilles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/305010

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 roa 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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/10/305010/1

diff --git a/includes/filerepo/file/LocalFile.php 
b/includes/filerepo/file/LocalFile.php
index f7275fc..9a82bcc 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -961,6 +961,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()->push( $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)
@@ -1508,6 +1535,8 @@
                                # Update backlink pages pointing to this title 
if created
                                LinksUpdate::queueRecursiveJobsForTable( 
$that->getTitle(), 'imagelinks' );
                        }
+
+                       $that->prerenderThumbnails();
                } );
 
                if ( !$reupload ) {
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index 1185c4d..ea19024 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -751,27 +751,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: newchange
Gerrit-Change-Id: If5b94e83d8bbcc6aebfe7193f7b580f03cbd627d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to