Bug #49444

No file found for given UID after deleting a referenced image file

Added by Christian Eßl about 2 years ago. Updated over 1 year ago.

Status:Closed Start date:2013-06-26
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:File Abstraction Layer (FAL) Spent time: -
Target version:-
TYPO3 Version:6.1 Is Regression:No
PHP Version: Sprint Focus:
Complexity:medium

Description

How to reproduce:

- create a content element of type "image" with a referenced image file
- delete the image file in filelist
- try to access the previously created content element in the backend.

You will get the following exception:

Uncaught TYPO3 Exception
#1317178604: No file found for given UID. (More information)

TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException thrown in file
/usr/www/users/naderq/typo3/sysext/core/Classes/Resource/ResourceFactory.php in line 266.


Related issues

related to Core - Bug #46785: FileDoesNotExistException Resolved 2013-03-29
related to Core - Bug #50575: Fatal error while adding files to tt_content Closed 2013-07-30

History

#1 Updated by Jigal van Hemert about 2 years ago

  • Category set to File Abstraction Layer (FAL)
  • Complexity set to medium

#2 Updated by Alexander Opitz about 2 years ago

  • Status changed from New to Needs Feedback
  • Assigned To set to Alexander Opitz

Do you have a backtrace? Did you use TYPO3 CMS 6.1.0 or 6.1.1?

#3 Updated by Benjamin no-lastname-given about 2 years ago

I have a similar Problem:
After deleting files & records of a YAG-Gallery i always get this exception in the backend when i try to open the page in the YAG-View.
This is the stacktrace:
http://htmlpaste.com/16ee05c3a40796e2a7c96e80942ecbe29fbd0cb9

#4 Updated by Benjamin no-lastname-given about 2 years ago

Here some more information:
I used TYPO3 6.1.1.
The file causing the exception was : "/typo3conf/ext/yag/Resources/Public/Icons/imageNotFound.jpg".
The cause for the exception was that the record in "sys_file" for this file had deleted=1.
So a attempt to use this file and scale ist resulted in the exception.

I did not expect that FAL is used for such resources files - is that necessary?

I fixed my problem by setting deleted=0 with phpmyadmin.
Sadly i do not know how/when the deleted=1 has been set..

#5 Updated by Alexander Opitz almost 2 years ago

@Benjamin

This problem was caused by another issue which should be fixed with 6.1.3 (IMHO, but maybe I remember false and it will only be fixed in 6.2).

So my question stays:
@Christian Eßl
Can you post a backtrace please?

#6 Updated by Ernesto Baschny almost 2 years ago

  • Target version set to next-patchlevel

This will most probably also be fixed with the patch for #51562, which should also be backported to 6.0 and 6.1.

#7 Updated by Alexander Opitz almost 2 years ago

  • Is Regression set to No

Please test this with TYPO3 6.1.5 (will be released tomorrow if nothing critical happens today) and report then if it is working.

#8 Updated by Alexander Opitz over 1 year ago

Hi,

as 6.1.5 is released. Is the issue gone or does it persist in the new version of TYPO3 CMS?

#9 Updated by Stefan Froemken over 1 year ago

Hi Alexander,

this problem is still there. Here is a backtrace:

Uncaught TYPO3 Exception
#1317178604: No file found for given UID. (More information)

TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException thrown in file
/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/core/Classes/Resource/ResourceFactory.php in line 348.

14 TYPO3\CMS\Core\Resource\ResourceFactory::getFileObject("226165")

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/core/Classes/Resource/FileReference.php:
00110: $factory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
00111: }
00112: $this->originalFile = $factory->getFileObject($fileReferenceData['uid_local']);
00113: $this->fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
00114: if (!is_object($this->originalFile)) {

13 TYPO3\CMS\Core\Resource\FileReference::__construct(array)
12 ReflectionClass::newInstanceArgs(array)

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
04147: array_shift($constructorArguments);
04148: $reflectedClass = new \ReflectionClass($finalClassName);
04149: $instance = $reflectedClass->newInstanceArgs($constructorArguments);
04150: } else {
04151: $fullyQualifiedClassName = '\\' . $finalClassName;

11 TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("TYPO3\CMS\Core\Resource\FileReference", array)

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/core/Classes/Resource/ResourceFactory.php:
00576: public function createFileReferenceObject(array $fileReferenceData) {
00577: /** @var FileReference $fileReferenceObject */
00578: $fileReferenceObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileReference', $fileReferenceData);
00579: return $fileReferenceObject;
00580: }

10 TYPO3\CMS\Core\Resource\ResourceFactory::createFileReferenceObject(array)

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/core/Classes/Resource/ResourceFactory.php:
00561: }
00562: }
00563: $this->fileReferenceInstances[$uid] = $this->createFileReferenceObject($fileReferenceData);
00564: }
00565: return $this->fileReferenceInstances[$uid];

9 TYPO3\CMS\Core\Resource\ResourceFactory::getFileReferenceObject("15140")

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/backend/Classes/Utility/BackendUtility.php:
01557: );
01558: foreach ($referenceUids as $referenceUid) {
01559: $fileReferenceObject = ResourceFactory::getInstance()->getFileReferenceObject($referenceUid['uid']);
01560: $fileObject = $fileReferenceObject->getOriginalFile();
01561:

8 TYPO3\CMS\Backend\Utility\BackendUtility::thumbCode(array, "tt_content", "image", "../../../")

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php:
00532: */
00533: public function thumbCode($row, $table, $field) {
00534: return BackendUtility::thumbCode($row, $table, $field, $this->backPath);
00535: }
00536:

7 TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList::thumbCode(array, "tt_content", "image")

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/backend/Classes/View/PageLayoutView.php:
01287: if ($row['CType'] 'textpic' || $row['CType'] 'image') {
01288: if ($row['image']) {
01289: $out .= $this->thumbCode($row, 'tt_content', 'image') . '
';
01290: if ($row['imagecaption']) {
01291: $out .= $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '
';

6 TYPO3\CMS\Backend\View\PageLayoutView::tt_content_drawItem(array, boolean)

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/backend/Classes/View/PageLayoutView.php:
00456: !$this->tt_contentConfig['languageMode']);
00457: $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
00458: $innerContent = '
' . $this->tt_content_drawItem($row, $isRTE) . '
';
00459: $singleElementHTML .= '
' . $innerContent . '
' . $this->tt_content_drawFooter($row);
00460: // NOTE: this is the end tag for

5 TYPO3\CMS\Backend\View\PageLayoutView::getTable_tt_content(1)

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/backend/Classes/View/PageLayoutView.php:
00203: break;
00204: case 'tt_content':
00205: return $this->getTable_tt_content($id);
00206: break;
00207: }

4 TYPO3\CMS\Backend\View\PageLayoutView::getTable("tt_content", 1, "")

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php:
00435: }
00436: // Finally, render the list:
00437: $this->HTMLcode .= $this->getTable($tableName, $this->id, implode(',', $fields));
00438: }
00439: }

3 TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList::generateList()

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/backend/Classes/Controller/PageLayoutController.php:
00938: $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
00939: // Generate the list of elements here:
00940: $dblist->generateList();
00941: // Adding the list content to the tableOutput variable:
00942: $tableOutput[$table] = ($h_func ? $h_func . '

' : '') . $dblist->HTMLcode . ($h_func_b ? '
' . $h_func_b : '');

2 TYPO3\CMS\Backend\Controller\PageLayoutController::renderListContent()

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/backend/Classes/Controller/PageLayoutController.php:
00541: } else {
00542: // All other listings
00543: $body .= $this->renderListContent();
00544: }
00545: // Setting up the buttons and markers for docheader

1 TYPO3\CMS\Backend\Controller\PageLayoutController::main()

/kunden/removedPath/typo3cms/typo3_src-6.2.0-2013-11-27/typo3/sysext/cms/layout/db_layout.php:
00139: }
00140: $SOBE->clearCache();
00141: $SOBE->main();
00142: $SOBE->printContent();

#10 Updated by Stefan Froemken over 1 year ago

This is only a "bad" workaround, if you don't have a backup, removed some entries in sys_file manually by DB or something else:

Find all tt_content-elements which are broken (sys_file record was not found):

SELECT DISTINCT tt_content.uid AS Inhaltselement, tt_content.pid AS Seite
FROM tt_content
LEFT JOIN sys_file_reference
ON tt_content.uid = sys_file_reference.uid_foreign
LEFT JOIN sys_file
ON sys_file_reference.uid_local = sys_file.uid
WHERE sys_file_reference.tablenames = "tt_content" 
AND sys_file.uid IS NULL

Make a screenshot or export it as CSV with help of phpMyAdmin.

Delete all references records where NO sys_file-record exists:

DELETE FROM sys_file_reference
USING tt_content
LEFT JOIN sys_file_reference
ON tt_content.uid = sys_file_reference.uid_foreign
LEFT JOIN sys_file
ON sys_file_reference.uid_local = sys_file.uid
WHERE sys_file_reference.tablenames = "tt_content" 
AND sys_file.uid IS NULL

Now you can access pagemodul and add missing images again with help of CSV-Export of first Query.

Stefan

#11 Updated by Alexander Opitz over 1 year ago

Hi Stefan,

TYPO3\CMS\Core\Resource\ResourceFactory::getFileObject("226165")

uid 226165? Do you realy have so much file objects in this typo3 installation? What is the highest uid in your sys_file table?

Maybe something else went wrong.

#12 Updated by Stefan Froemken over 1 year ago

Hello Alexander,

the highest value is 377.174. And a COUNT of all records is nearly 60.000. We have imported nearly 47.000 files from DAM.

Stefan

#13 Updated by Stefan Froemken over 1 year ago

You can close this ticket now. Many patches were merged into the core in the last months. And one of them also solves this problem here.

#14 Updated by Alexander Opitz over 1 year ago

  • Status changed from Needs Feedback to Closed
  • Assigned To deleted (Alexander Opitz)
  • Target version deleted (next-patchlevel)

After discussion with Stefan directly, the issue behind the high uid numbers are cleared out and also was resolved.

Thanks Stefan.

Also available in: Atom PDF