LocalFile::prerenderThumbnails: Limit the number of thumbnail jobs triggered

Bug: T309114
Change-Id: I70a24ee42ff64d71c8e52c9138290b4042308ce0
This commit is contained in:
James D. Forrester 2022-05-24 13:18:12 -04:00
parent 3e2653f83b
commit baf2f5ef22

View file

@ -74,6 +74,9 @@ class LocalFile extends File {
/** @var string Metadata serialization: JSON */
private const MDS_JSON = 'json';
/** @var int Maximum number of pages for which to trigger render jobs */
private const MAX_PAGE_RENDER_JOBS = 50;
/** @var bool Does the file exist on disk? (loadFromXxx) */
protected $fileExists;
@ -1450,7 +1453,11 @@ class LocalFile extends File {
foreach ( $sizes as $size ) {
if ( $this->isMultipage() ) {
for ( $page = 1; $page <= $this->pageCount(); $page++ ) {
// (T309114) Only trigger render jobs up to MAX_PAGE_RENDER_JOBS to avoid
// a flood of jobs for huge files.
$pageLimit = min( $this->pageCount(), self::MAX_PAGE_RENDER_JOBS );
for ( $page = 1; $page <= $pageLimit; $page++ ) {
$jobs[] = new ThumbnailRenderJob(
$this->getTitle(),
[ 'transformParams' => [