Bug #53712
closedInvalid refindex data for file relations
100%
Description
Currently the getRelations_procDB
method in the ReferenceIndex
generates invalid data for sys_file_reference
relations.
First it will always return a non empty array, even if no relations are found. This will lead to a lot of senseless refindex entries that have no related records. (found this out after applying patch from https://review.typo3.org/25422/).
The second problem is, that the the id
entry in the resulting array will contain an array again, and not the UID of the file as expected. This leads to a query that tries to insert an array in the sys_refindex table which will result in a PHP Warning.
Finally the structure of the resulting array is invalid, because all entries will added beneath the zero index of a parent array that is not needed:
array(1) { [0] => array(2) { [0] => array(2) { 'table' => string(8) "sys_file" 'id' => int(123) } [1] => array(2) { 'table' => string(8) "sys_file" 'id' => int(1234) } } }
The correct array structure would look like this (without the parent array):
array(2) { [0] => array(2) { 'table' => string(8) "sys_file" 'id' => int(123) } [1] => array(2) { 'table' => string(8) "sys_file" 'id' => int(1234) } }
Updated by Gerrit Code Review about 11 years ago
- Status changed from New 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/25476
Updated by Gerrit Code Review almost 11 years 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/25476
Updated by Gerrit Code Review almost 11 years 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/25476
Updated by Alexander Stehlik almost 11 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset f2e37267a284807593ef762e82bd52ea64647501.
Updated by Pierre van Rooden almost 11 years ago
Tested this on 6.1.7 by porting the changed files. I would like to see this ported to the 6.1 branch, taking into account the comment below.
In 6.1.7 this is the situation after I added the changed files:
The code no longer creates sys_refindex entries for the file_reference foreign_id field. As far as I can see it now skips that field (since it is no longer a select field).
That is an improvement on the older code as it means that it also doesn't make invalid entries (containing the wrong table name). We (NTR) use a different table than tt_content to link from, and the older code would make wrong refindex entries. The result with the old code was that if you ran the cleaner code after 'fixing' the refindex, it removed valid file_reference entries.
That doesn't happen now, so I would be happy for the patch to be worked in the current 6.1 branch despite it not being perfect.
However I don't think it is correct yet, as the file_reference foreign_id field is now entirely skipped. By skipping the field you may not be able to clean up obsolete file_reference records later.
A proper fix would be to use the tablenames field when creating the refindex for sys_file_reference.
Updated by Frans Saris almost 11 years ago
What would be a use-case that creates obsolute sys_file_reference records? When a file is deleted all the sys_file_reference records are deleted to.
Updated by Gerrit Code Review almost 11 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26645
Updated by Gerrit Code Review almost 11 years ago
Patch set 1 for branch TYPO3_6-0 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26646
Updated by Alexander Stehlik almost 11 years ago
- Status changed from Under Review to Resolved
Applied in changeset c4703dbb33ef67444900d1d5d18e1f0bc9eee73d.