Project

General

Profile

Actions

Bug #56150

closed

Exception with "Hidden" sys_file_references when using levelmedia - RootlineUtility::enrichWithRelationFields ignores disable field

Added by Christian Reiter about 10 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
Start date:
2014-02-20
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.1
PHP Version:
5.4
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Test scenario in TYPO3 6.2:

A Page (e.g. ID=15) has 2 sys_file_reference relations (pages.media)

Frontend output is via levelmedia, for instance

file {
import.data = levelfield:1, media
treatIdAsReference = 1
import.listNum = 0
}

In 6.2 whichever reference is sorted to the top in the backend is output as expected so far.
(in 6.1 this does not work because sorting_foreign was ignored http://forge.typo3.org/issues/46383#change-204405) but that is fixed for 6.2 with https://review.typo3.org/#/c/26727/

Now the editor uses the "Light bulb" icon to hide the first reference.

Expected result: The second reference should be shown now.

Observed result:
Exception thrown "#1317178794: No fileusage (sys_file_reference) found for given UID"

Reason:

  • levelmedia means the rootline is checked for the references.
  • They are put there by the function enrichWithRelationFields in \TYPO3\CMS\Core\Utility\RootlineUtility
  • This loads relations by generating a SQL query.
  • This query checks that record isn't deleted=1 and in 6.2 also orders by foreign_sortby (in 6.1 it doesn't)
  • However it does not check for disabled=1

This means that both sys_file_reference entries go into the "enriched" rootline data.

Then the import.listNum = 0 means that the first one is returned.

That one is hidden.

So when we get to TYPO3\CMS\Core\Resource\ResourceFactory::getFileReferenceObject the exception is thrown because only the hidden reference has arrived.

This is pretty confusing for editors as they are using seemingly harmless, legal operations in TYPO3 ("hiding") and this ends up killing entire page trees in the frontend. As when the rootline is checked of course all the pages below can be affected. A typical application of levelmedia is banners for a chapter and so this situation could "exceptionalize" an entire website chapter just due to hinding a banner.
This is hitting live projects with 6.1

In 6.2 they can solve that by resorting the references but in 6.1 they can't

It would be easy to change enrichWithRelationFields to respect $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] in general or for sys_file_reference specifically.

However the comment in TYPO3\CMS\Frontend\Page\PageRepository::getRootLine says:

NOTICE: This function only takes deleted pages into account! So hidden, starttime and endtime restricted pages are included no matter what.

So this seems to be necessary/desired behaviour?

Is it possible to make levelmedia in 6.1/6.2 "hidden-safe" without breaking that behaviour (e.g. by applying the hidden check only for sys_file_reference relations in enrichWithRelationFields )

Or could at least the exception "No fileusage (sys_file_reference) found for given UID" be replaced with a more graceful failure that allows the page to be rendered? Editors will then just scratch their heads why there is no image instead of going into panic.

This was all not a problem in 4.x because pages.media was just a comma separated list of values, there was no "hiding" of a relation from that, and no foreign sorting either. So checking hidden was indeed irrelevant for levelmedia in 4.x


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #46383: levelmedia ignores sorting of media recordsClosed2013-03-17

Actions
Actions

Also available in: Atom PDF