When a content element is saved that references a deleted file than a TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException exception is thrown.
The stacktrace looks like this:
Uncaught TYPO3 Exception
#1317178604: No file found for given UID: 228279 (More information)
TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException thrown in file
/var/www/typo3/vendor/typo3/cms/typo3/sysext/core/Classes/Resource/ResourceFactory.php in line 353.
12 TYPO3\CMS\Core\Resource\ResourceFactory::getFileObject("228279")
/var/www/typo3/public_html/typo3conf/ext/media/Classes/Hook/DataHandlerHook.php:
00112: // After collecting files, update the column "number_of_references".
00113: foreach ($this->getFileToProcess() as $fileIdentifier) {
00114: $file = ResourceFactory::getInstance()->getFileObject($fileIdentifier);
00115: $numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
00116:
11 Fab\Media\Hook\DataHandlerHook::processDatamap_afterAllOperations(TYPO3\CMS\Core\DataHandling\DataHandler)
/var/www/typo3/vendor/typo3/cms/typo3/sysext/core/Classes/DataHandling/DataHandler.php:
01347: foreach ($hookObjectsArr as $hookObj) {
01348: if (method_exists($hookObj, 'processDatamap_afterAllOperations')) {
01349: $hookObj->processDatamap_afterAllOperations($this);
01350: }
01351: }
10 TYPO3\CMS\Core\DataHandling\DataHandler::process_datamap()
/var/www/typo3/vendor/typo3/cms/typo3/sysext/backend/Classes/Controller/EditDocumentController.php:
00585: // Perform the saving operation with TCEmain:
00586: $tce->process_uploads($_FILES);
00587: $tce->process_datamap();
00588: $tce->process_cmdmap();
00589: // If pages are being edited, we set an instruction about updating the page tree after this operation.
9 TYPO3\CMS\Backend\Controller\EditDocumentController::processData()
/var/www/typo3/vendor/typo3/cms/typo3/sysext/backend/Classes/Controller/EditDocumentController.php:
02037: // Checks, if a save button has been clicked (or the doSave variable is sent)
02038: if ($this->doProcessData()) {
02039: $this->processData();
02040: }
02041:
8 TYPO3\CMS\Backend\Controller\EditDocumentController::mainAction(TYPO3\CMS\Core\Http\ServerRequest, TYPO3\CMS\Core\Http\Response)
7 call_user_func_array(array, array)
/var/www/typo3/vendor/typo3/cms/typo3/sysext/backend/Classes/Http/RouteDispatcher.php:
00052: $targetIdentifier = $route->getOption('target');
00053: $target = $this->getCallableFromTarget($targetIdentifier);
00054: return call_user_func_array($target, [$request, $response]);
00055: }
00056:
6 TYPO3\CMS\Backend\Http\RouteDispatcher::dispatch(TYPO3\CMS\Core\Http\ServerRequest, TYPO3\CMS\Core\Http\Response)
/var/www/typo3/vendor/typo3/cms/typo3/sysext/backend/Classes/Http/RequestHandler.php:
00166: /** @var RouteDispatcher $dispatcher */
00167: $dispatcher = GeneralUtility::makeInstance(RouteDispatcher::class);
00168: return $dispatcher->dispatch($request, $response);
00169: }
00170: }
5 TYPO3\CMS\Backend\Http\RequestHandler::dispatch(TYPO3\CMS\Core\Http\ServerRequest)
/var/www/typo3/vendor/typo3/cms/typo3/sysext/backend/Classes/Http/RequestHandler.php:
00093: if ($routingEnabled) {
00094: try {
00095: return $this->dispatch($request);
00096:
00097: // When token was invalid redirect to login
4 TYPO3\CMS\Backend\Http\RequestHandler::handleRequest(TYPO3\CMS\Core\Http\ServerRequest)
/var/www/typo3/vendor/typo3/cms/typo3/sysext/core/Classes/Core/Bootstrap.php:
00300:
00301: // Execute the command which returns a Response object or NULL
00302: $this->response = $requestHandler->handleRequest($request);
00303: return $this;
00304: }
3 TYPO3\CMS\Core\Core\Bootstrap::handleRequest(TYPO3\CMS\Core\Http\ServerRequest)
/var/www/typo3/vendor/typo3/cms/typo3/sysext/backend/Classes/Http/Application.php:
00092: }
00093:
00094: $this->bootstrap->handleRequest($this->request);
00095:
00096: if ($execute !== null) {
2 TYPO3\CMS\Backend\Http\Application::run()
/var/www/typo3/vendor/typo3/cms/typo3/index.php:
00018: call_user_func(function () {
00019: $classLoader = require __DIR__ . '/../vendor/autoload.php';
00020: (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
00021: });
1 {closure}()
/var/www/typo3/vendor/typo3/cms/typo3/index.php:
00019: $classLoader = require __DIR__ . '/../vendor/autoload.php';
00020: (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
00021: });
The problem can be reproduced by following those steps:
Upload a file
Link the file in a content element (I tried this using the RTE)
Delete the file again (I used the TYPO3 built in file list for this because the file list from this extension is preventing deletion of referenced files)
Try to edit the content element again. After pressing the "save" button the exception will be thrown.
I’ll provide a PR that will catch the exception within the hook.
When a content element is saved that references a deleted file than a
TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
exception is thrown.The stacktrace looks like this:
The problem can be reproduced by following those steps:
I’ll provide a PR that will catch the exception within the hook.
A similar bug was also present in the TYPO3 Core: https://forge.typo3.org/issues/58013
FYI @fourty2 @lindemann-medien