Project

General

Profile

Actions

Bug #53712

closed

Invalid refindex data for file relations

Added by Alexander Stehlik over 10 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2013-11-17
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.4
Tags:
Complexity:
easy
Is Regression:
No
Sprint Focus:

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)
  }
}

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #53713: Reference index ignores sys_file_reference deleted flagClosed2013-11-17

Actions
Actions #1

Updated by Gerrit Code Review over 10 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

Actions #2

Updated by Gerrit Code Review over 10 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

Actions #3

Updated by Gerrit Code Review over 10 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

Actions #4

Updated by Alexander Stehlik over 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #5

Updated by Pierre van Rooden about 10 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.

Actions #6

Updated by Frans Saris about 10 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.

Actions #7

Updated by Gerrit Code Review about 10 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

Actions #8

Updated by Gerrit Code Review about 10 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

Actions #9

Updated by Alexander Stehlik about 10 years ago

  • Status changed from Under Review to Resolved
Actions #10

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF