Bug #80875

Updated by Sascha Egerer over 4 years ago

I've multiple problems with the relation handler if i modify (edit, delete) a record that is stored on a page where many records of that type exist. 

 Steps to reproduce: 

 # Install tt_address (should also work with any other record that uses categories) 
 # Create a sys_category record 
 # Create a Page of type folder 
 # Store 70.000 Records of type tt_address in that folder and put all records into the same sys_category 

 Steps that fail: 

 # Open one of the records and try to save the record 
 PHP Fatal error:    Allowed memory size of 1073741824 bytes exhausted (tried to allocate 294912 bytes) in /xxx/vendor/typo3/cms/typo3/sysext/core/Classes/Database/ReferenceIndex.php on line 226 
 </pre> </rep> 

 # Try to delet a record 
 Core: Exception handler (WEB): Uncaught TYPO3 Exception: An exception occurred while executing 'SELECT `uid`, `t3ver_oid`, `t3ver_state` FROM `tt_address` WHERE (`pid` = ?) AND (`t3ver_oid` IN (?, ?, ?, ?, ### HERE ARE AROUND 70.000 PLACEHOLDERS!### , ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) AND (`t3ver_wsid` <> ?) ORDER BY `t3ver_state` DESC' with params [-1, 6877, ... ###HERE ARE AROUND 70.000 IDS!###, 0]: 

 Prepared statement contains too many placeholders | Doctrine\DBAL\Exception\DriverException thrown in file /xxx/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php in line 115. Requested URL: https://xxx/typo3/index.php?route=%2Frecord%2Fcommit&token=b7ea833b34189d38b4fd1100f4a55766c16b0613&redirect=%2Ftypo3%2Findex.php%3FM%3Dweb_list%26moduleToken%3D114051d1fe77316e97e2afd42f8034d93a647a7d%26id%3D1316%26table%3D%26imagemode%3D1%26search_field%3Da%26table%3Dtt_address&cmd[tt_address][1300][delete]=1&prErr=1 

 There a multiple probelms but all of them are related to the realtion handling. 
 The relation handler does fetch all ids and puts them into a prepared statement. That fails as prepared statements to only allow 65.536 placeholders. 
 So this should be solved by a subquery and not by fetching all ids. 
 The other problem is, that all records are fetched and this ends up in a excessive memory usage. 

 It looks like all actions are executed as expected (records are deleted and saved) but the state of the databse is or can be inconsistent as the save process fails somewhere in the middle.