Commit e53c7f64 authored by crell's avatar crell Committed by Christian Kuhn
Browse files

[TASK] Make ImageProcessingService strictly typed

Also switches to constructor property promotion in the process.

Used command:

> ./Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #98004
Releases: main
Change-Id: Ic55548afe59654da4ab7fc7ab5a4cfb408ab38d8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75266

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent e2cc055d
......@@ -1100,11 +1100,6 @@ parameters:
count: 1
path: ../../typo3/sysext/core/Classes/Resource/Service/FileProcessingService.php
-
message: "#^Parameter \\#2 \\$key of method TYPO3\\\\CMS\\\\Core\\\\Locking\\\\ResourceMutex\\:\\:acquireLock\\(\\) expects string, int given\\.$#"
count: 1
path: ../../typo3/sysext/core/Classes/Resource/Service/ImageProcessingService.php
-
message: "#^Strict comparison using \\=\\=\\= between TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage and null will always evaluate to false\\.$#"
count: 1
......
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
......@@ -27,29 +29,11 @@ use TYPO3\CMS\Core\Resource\ProcessedFileRepository;
*/
class ImageProcessingService
{
/**
* @var ProcessedFileRepository
*/
private $processedFileRepository;
/**
* @var Context
*/
private $context;
/**
* @var ResourceMutex
*/
private $locker;
public function __construct(
ProcessedFileRepository $processedFileRepository,
Context $context,
ResourceMutex $locker
private readonly ProcessedFileRepository $processedFileRepository,
private readonly Context $context,
private readonly ResourceMutex $locker,
) {
$this->processedFileRepository = $processedFileRepository;
$this->context = $context;
$this->locker = $locker;
}
public function process(int $processedFileId): ProcessedFile
......@@ -58,7 +42,7 @@ class ImageProcessingService
$processedFile = $this->processedFileRepository->findByUid($processedFileId);
try {
$this->validateProcessedFile($processedFile);
$this->locker->acquireLock(self::class, $processedFileId);
$this->locker->acquireLock(self::class, (string)$processedFileId);
// Fetch the processed file again, as it might have been processed by another process while waiting for the lock
/** @var ProcessedFile $processedFile */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment