Bug #47869

Failed localization of FILES content object related to pages

Added by Eugene no-lastname-given over 2 years ago. Updated about 1 year ago.

Status:Resolved Start date:2013-05-03
Priority:Should have Due date:
Assigned To:Eugene no-lastname-given % Done:

100%

Category:Frontend Spent time: -
Target version:-
TYPO3 Version:6.1 Is Regression:No
PHP Version: Sprint Focus:
Complexity:

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 Core - Bug #58352: Invalid localization overlay of cObject FILES Resolved 2014-04-30
related to Core - Bug #48113: typoscript FILES object always uses default language when... Resolved 2013-05-11
related to Core - Bug #57272: Extbase doesn't handle FAL translations correctly Under Review 2014-03-25
related to Core - Bug #60998: PageRepository::shouldFieldBeOverlaid raises PHP warning Resolved 2014-08-15

Associated revisions

Revision d976053c
Added by Oliver Hader about 1 year ago

[BUGFIX] Invalid localization overlay of cObject FILES

The TypoScript cObject FILES does not consider localization
overlays and behavior correctly when it comes additional
translation table (e.g. for pages).

Concerning pages_language_overlay.media, there is no default
fallback to the values of the default language. This behavior
is the same to TYPO3 4.5. If the localization shall fallback
to the default language, the "mergeIfNotBlank" property needs
to be used for the accordant field.

For having the localization handling working properly the
FILES cObject section "references" must not set the properties
"table" and "uid" - otherwise the values will just be overriden
by those TypoScript settings.

Resolves: #58352
Resolves: #47869
Releases: 6.2
Change-Id: I8e915654e5ab1ed1eafe86411930f9fbfcc225ae
Reviewed-on: https://review.typo3.org/29739
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter

Revision 90b0b4a3
Added by Steffen Ritter about 1 year ago

[BUGFIX] FollowUp to "Invalid localization overlay of cObject FILES"

When fixing language overlay of cObject FILES, the mocking in the unit
test was not adapted.

Resolves: #58352
Resolves: #47869
Releases: 6.2
Change-Id: I8f939e31a13e437e437624dfccddf5f39526fb8b
Reviewed-on: https://review.typo3.org/30666
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel

History

#1 Updated by Thorsten Kahler about 2 years ago

  • Category set to Frontend
  • Status changed from New to Needs Feedback
  • Assigned To set to Eugene no-lastname-given

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 almost 2 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:

1$localizedUid = $this->cObj->data['_LOCALIZED_UID'];
2if ($table === 'pages' && isset($this->cObj->data['_PAGES_OVERLAY_UID']) && intval($this->cObj->data['_PAGES_OVERLAY_LANGUAGE']) > 0) {
3    $table = 'pages_language_overlay';
4    $localizedUid = $this->cObj->data['_PAGES_OVERLAY_UID'];
5}
6$referencesForeignTable = $this->stdWrapValue('table', $conf['references.'], $table);
7$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 almost 2 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 almost 2 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 2 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 2 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 1 year 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 1 year 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 1 year ago

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

#10 Updated by Gerrit Code Review over 1 year 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 about 1 year 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 about 1 year 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 about 1 year 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 about 1 year ago

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

#15 Updated by Gerrit Code Review about 1 year 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 about 1 year 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 about 1 year 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 about 1 year ago

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

Also available in: Atom PDF