Bug #81208

Updated by Xavier Perseguers about 5 years ago


 This is quite tricky and could not understand how to reproduce it in a vanilla install. 

 h2. Context 

 * The problem happens for me when previewing a page from a workspace with a menu of categories associated to EXT:news records. 
 * In my case I have a custom extended domain model for news records but it does not seem to be related, I removed corresponding columns/fields from the query below 

 Preview crashes with: 

 An exception occurred while executing 'SELECT `uid_local`, `uid_foreign`, `tablenames`, `sorting`, `sorting_foreign`, `fieldname`, `uid`, `pid`, `tstamp`, `crdate`, `cruser_id`, `deleted`, `hidden`, `starttime`, 
 `endtime`, `t3ver_oid`, `t3ver_id`, `t3ver_wsid`, `t3ver_label`, `t3ver_state`, `t3ver_stage`, `t3ver_count`, `t3ver_tstamp`, `t3ver_move_id`, `t3_origuid`, `sys_language_uid`, `l10n_parent`, `l10n_diffsource`, 
 `title`, `description`, `parent`, `items`, `fe_group`, `images`, `single_pid`, `shortcut`, `import_id`, `import_source`, `seo_title`, `seo_description`, `seo_headline`, `seo_text`, `l10n_state` 
 FROM `sys_category` WHERE (`pid` = ?) AND (`t3ver_oid` = ?) AND (`t3ver_wsid` = ?) AND (`sys_category`.`deleted` = 0) LIMIT 1' with params [-1, 29, 2]: Unknown column 'uid_local' in 'field list'  

 Call stack shows: 


 After quite some deep debugging, I could understand the context: 

 * This happens when the rows array which need to be overlaid in @\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::doLanguageAndWorkspaceOverlay()@ are the result of a JOIN (in my case a JOIN from @sys_category@ and @sys_category_record_mm@ 
 * Each row is thus containing fields coming from both tables 
 * The test on @$source@ at the beginning of method @doLanguageAndWorkspaceOverlay@ properly detects that a JOIN is in use and extracts the right table (@sys_category@) 
 * There are some tests whether the "original" record needs to be fetched, for instance when a move is detected, that's not invoked in my case 
 * There is another test which detects that current record is a translation already and then would fetch the parent record instead, this is where the problem lies 
 * If current record is a **default language** record **AND** we are in the context of fetching the content of a workspace (method is invoked multiple times with same record causing no errors until the context of the call is the actual workspace preview), then it bypasses the action of reloading the record from database 
 * Since it bypasses this reload, call to @versionOL@ is made with a row containing additional columns from @sys_category_record_mm@ and since the test at the very beginning of method @versionOL@ succeeds, there is a call to method @getWorkspaceVersionOfRecord@ with those invalid additional columns and this is the source of the SQL failure 

 h2. Solution Found 

 The test to reload the original record is extended to check if we are in the context of a workspace preview and if so, ensure no additional columns are present