Issue Bug Closed

#53712Invalid refindex data for file relations

Alexander Stehlik 11/17/13, 13:50 updated 10/02/18, 12:08

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

Reviews 3