Bug #37892
closedWorkspace preview with non default language causes SQL error in language iso code determination
100%
Description
What I tried¶
The setup is with multiple page trees (which I don't think are relevant here) which may have multiple languages each. I use currently one workspace. I tried to view a page in a non-default language (L=4) while being in the workspace in the backend. The frontend output was a workspace preview like I expected it except for the sql error below.
What happens¶
The method tslib_fe::settingLanguage() tries to determine the language iso code by looking it up in static_info_tables. This is done using t3lib_page::getRawRecord() which does a version overlay regardless whether the table supports versioning or not. Neither sys_language nor static_languages support versioning (which seems fine to me). But obviously a version overlay on a table that does not have versioning columns can not work and generates invalid sql:
caller t3lib_DB::exec_SELECTquery ERROR Unknown column 't3ver_oid' in 'where clause' lastBuiltQuery SELECT static_lang_isocode FROM sys_language WHERE pid=-1 AND t3ver_oid=0 AND t3ver_wsid=1 LIMIT 1 debug_backtrace require(3_src/typo3/sysext/cms/tslib/index_ts.php),3_src/index.php#78 // tslib_fe->settingLanguage#305 // t3lib_pageSelect->getRawRecord#2349 // t3lib_pageSelect->versionOL#862 // t3lib_pageSelect->getWorkspaceVersionOfRecord#1152 // t3lib_DB->exec_SELECTgetSingleRow#1290 // t3lib_DB->exec_SELECTquery#310 // t3lib_DB->debug#191
An easy way to avoid the invalid SQL is to set the fourth parameter ($noWSOL) of t3lib_page::getRawRecord to TRUE, but this feels more like a workaround than a fix. To me it would make more sense to only apply version overlay if the table supports this, but as there are hundreds of places that could break if I touch such a central method, I feel not confident enough to do that.