Project

General

Profile

Bug #86405

Updated by Rainer Roskothen about 6 years ago

Hello, 

 in TYPO3 9.4 the use of setRespectSysLanguage has no effect. I'm developing an extension to search a list of media. Each medium has an english record and a translated german record in a table media, so for example 

 (English) 
 uid: 11 
 sys_language_uid: 0 
 l10n_parent: 0 
 medium: water 

 (German) 
 uid: 12 
 sys_language_uid: 1 
 l10n_parent: 11 
 medium: Wasser 

 In the media repository I set up a query like 

 $query = $this->createQuery(); 
 $query->getQuerySettings()->setRespectSysLanguage(true); 
 $constraint = $query->like('medium', '%' . $medium . '%'); 
 $query->matching($constraint); $query->matching($constrain); 
 return $query->execute(); 

 The expected result is: record 11 on the english page and record 12 on the german page. Currently I get the follwing result: record 11 on the english page, no record on the german page. 

 Prompting the underlying SQL query (english, short version) looks like: 

 SELECT * FROM media media 
 WHERE (medium LIKE '%water%') AND (sys_language_uid IN (0, -1)) 
 AND (pid = 278) AND ((deleted = 0) AND (t3ver_state <= 0) AND (pid <> -1) 
 AND (hidden = 0) AND (starttime <= 1538051940) AND ((endtime = 0) OR (endtime > 1538051940))) 

 and (german, short version) 

 SELECT * FROM media media 
 WHERE (medium LIKE '%wasser%') 
 AND ((sys_language_uid = -1) OR ((sys_language_uid = 1) AND (l10n_parent = 0)) 
 OR ((sys_language_uid = 0) AND (uid IN (SELECT l10n_parent FROM media WHERE (l10n_parent > 0) AND (sys_language_uid = 1) AND (deleted = 0))))) 
 AND (pid = 278) AND ((deleted = 0) AND (t3ver_state <= 0) AND (pid <> -1) 
 AND (hidden = 0) AND (starttime <= 1538051940) AND ((endtime = 0) OR (endtime > 1538051940))) 

 And now my questions: 
 1. Why is the table media nested two times in the query "FROM media media" ? 
 2. The term "OR ((sys_language_uid = 1) AND (l10n_parent = 0))" cause the empty result by excluding all records with sys_language_uid=1 and l10n_parent pointing to an uid of the english record. Why? 

 Eventually this issue is related to Bug #45873 which started in 2013 for TYPO3 6.0 and isn't solved yet. 

 Thanks for your attention and help 
 Rainer 

Back