Bug #47869

Failed localization of FILES content object related to pages

Added by Eugene Skomorokhov over 8 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Should have
Category:
Frontend
Target version:
-
Start date:
2013-05-03
Due date:
% Done:

100%

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

Description

Localization failed when references.table=pages used. The code in typo3/sysext/frontend/Classes/ContentObject/FlowPlayerContentObject.php line 73

if ($table === 'pages' && isset($this->cObj->data['_LOCALIZED_UID']) && intval($this->cObj->data['sys_language_uid']) > 0) {
    $table = 'pages_language_overlay';
}

doesn't working because of $this->cObj->data is NULL.


Related issues

Related to TYPO3 Core - Bug #48113: typoscript FILES object always uses default language when accessing page resource images of translated images Closed2013-05-11

Actions
Related to TYPO3 Core - Bug #58352: Invalid localization overlay of cObject FILESClosedOliver Hader2014-04-30

Actions
Related to TYPO3 Core - Bug #57272: Extbase doesn't handle FAL translations correctlyClosed2014-03-25

Actions
Related to TYPO3 Core - Bug #60998: PageRepository::shouldFieldBeOverlaid raises PHP warningClosed2014-08-15

Actions
#1

Updated by Thorsten Kahler over 8 years ago

  • Category set to Frontend
  • Status changed from New to Needs Feedback
  • Assignee set to Eugene Skomorokhov

Hi Eugene, I guess you meant line 73 in FilesContentObject.php, didn't you? Could you provide a little bit more elaborated example code, please?

#2

Updated by Alexander Stehlik about 8 years ago

Hi,

I just stumbled over this issue today. I'm not sure if there are other usecases for this but thats the problem I've got:

I'm using the media field to upload images I want to display in a MENU object. Here is some example TypoScript:

page = PAGE
page.10 = HMENU
page.10 {
  1 = TMENU
  1 {
    NO = 1
    NO.wrapItemAndSub = <p>|</p>
    NO.after.cObject = FILES
    NO.after.cObject  {
      references.fieldName = media
      renderObj = IMAGE
      renderObj {
        file.import.data = file:current:uid_local
        file.width = 100
      }
    }
  }
}

The problem as I understand it is indeed the line 77 in \TYPO3\CMS\Frontend\ContentObject\FilesContentObject. The field _LOCALIZED_UID is not available for pages.

The language overlay is done in two different methods in the \TYPO3\CMS\Frontend\Page\PageRepository class:

getPageOverlay() - this is responsible for pages and sets the fields _PAGES_OVERLAY, _PAGES_OVERLAY_UID and _PAGES_OVERLAY_LANGUAGE
getRecordOverlay() - this is responsible for other records and sets the field _LOCALIZED_UID

I modified the code a bit and this seems to work:

$localizedUid = $this->cObj->data['_LOCALIZED_UID'];
if ($table === 'pages' && isset($this->cObj->data['_PAGES_OVERLAY_UID']) && intval($this->cObj->data['_PAGES_OVERLAY_LANGUAGE']) > 0) {
    $table = 'pages_language_overlay';
    $localizedUid = $this->cObj->data['_PAGES_OVERLAY_UID'];
}
$referencesForeignTable = $this->stdWrapValue('table', $conf['references.'], $table);
$referencesForeignUid = $this->stdWrapValue('uid', $conf['references.'], isset($localizedUid) ? $localizedUid : $this->cObj->data['uid']);

If you think this makes sense I'll upload a patch to gerrit.

Cheers,
Alex

#3

Updated by Alexander Opitz about 8 years ago

  • Status changed from Needs Feedback to New

@Alexander Stehlik

I don't know if it make sense, but providing a patch to gerrit is always usefull.

#4

Updated by Philipp Gampe about 8 years ago

It might be a good idea to ping Helmut, as he seemed to have something with l10n in mind for FAL.

#5

Updated by Gerrit Code Review almost 8 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24884

#6

Updated by Alexander Stehlik almost 8 years ago

Sorry, I totally lost track of this one. A patch was submitted to gerrit.

Test environment

To set up a simple test environment for reproducing the error follow these steps

  • in the TYPO3 root create a sys_language record
  • create a new root page
  • create a TypoScript template in that root page and fill the setup section with the value documented below
  • adjust the config.sys_language_uid valid to your environment
  • create a translation for the root page
  • create a subpage
  • set an image in the media section of the subpage
  • create a translation for the subpage
  • set an image (a different one!) in media section the translation of the subpage
  • open the root page in the Frontend and switch the language (append &L=1)

TypoScript template setup

page = PAGE
page.10 = HMENU
page.10 {
  1 = TMENU
  1 {
    NO = 1
    NO.wrapItemAndSub = <p>|</p>
    NO.after.cObject = FILES
    NO.after.cObject  {
      references.fieldName = media
      renderObj = IMAGE
      renderObj {
        file.import.data = file:current:uid_local
        file.width = 100
      }
    }
  }
}

config.sys_language_uid = 0

[globalVar = GP:L = 1]
config.sys_language_uid = 1
[global]

Expected results

The expected result is to see the translated page title of the subpage and the image that was set in the media section of the translation record.

Before the patch is applied the image that was set in the page media section will be displayed.

After the patch the expected image set in the page translation media section is displayed.

#7

Updated by Gerrit Code Review over 7 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24884

#8

Updated by Gerrit Code Review over 7 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24884

#9

Updated by Gianpaolo Scrigna over 7 years ago

I can confirm the bug. Your patch works perfectly on Typo3 6.1.8
Thanks

#10

Updated by Gerrit Code Review over 7 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/29739

#11

Updated by Gerrit Code Review over 7 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/29739

#12

Updated by Gerrit Code Review over 7 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24884

#13

Updated by Gerrit Code Review over 7 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/29739

#14

Updated by Steffen Ritter over 7 years ago

  • Status changed from Under Review to Resolved
  • Is Regression set to No
#15

Updated by Gerrit Code Review over 7 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/30666

#16

Updated by Gerrit Code Review over 7 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/30666

#17

Updated by Gerrit Code Review over 7 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/30666

#18

Updated by Steffen Ritter over 7 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#19

Updated by Benni Mack almost 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF