Review main Merged

46395[BUGFIX] Avoid memory leak during file searches

Alexander Schnitzler CR +2 V +2 Easy +4 −6 updated 03/04/16, 19:05

Commit message

During the file search in the file module the search result
is only limited to possibly matching folders. That itself
decreases the search over all files in a storage but it
still does not prevent memory leaks, where the result
of possible folders contain a decent amount of files.

Example:
fileadmin has a total of 10.000 files.
fileadmin has a subfolder called foo
fileadmin/foo holds a subset of 1000 files.
fileadmin/foo holds the file bar

A search for bar asks the database for all folders that contain
files with the matching identifier bar. As a result, only the
folder fileadmin/foo is returned which already excludes 9000
possible files.

Still, the resultset contains 1000 files, whoose name is
compared php-wise with the search string. During that
foreach loop each a file object with a decent memory
footprint will be created. This easily exceeds the
available memory limit.

Review

  • Code review CR +2
    • Christian Kuhn +2
    • Frank Nägler +1
    • Daniel Maier +1
  • Verified V +2
    • Christian Kuhn +2
    • Daniel Maier +1

Issues 1

Files 2

Review log 9

  1. Alexander Schnitzler uploaded patch set 1 01/30/16, 14:43

  2. Mathias Brodala commented on patch set 1 01/30/16, 22:47

    whose

    FileIndexRepository.php:209

    Please make this the 2nd argument; this class is described "for internal use only" so this would be no API breakage.
  3. Frank Nägler commented on patch set 1 CR +1 02/29/16, 13:26

    FileIndexRepository.php:209 Reply

    the class is not annotated with @internal so this parameter must be added to the end of this public function.
  4. Mathias Brodala commented on patch set 1 02/29/16, 13:57

    FileIndexRepository.php:209 Reply

    I understand that but what about what I wrote? I'd say the missing @internal is a bug then.
  5. Daniel Maier voted on patch set 1 CR +1 V +1 03/04/16, 18:50

  6. Christian Kuhn commented on patch set 1 03/04/16, 18:59

    this is significantly quicker.

    FileIndexRepository.php:209 Reply

    this could be changed with another patch.
  7. Christian Kuhn voted on patch set 1 CR +2 V +2 03/04/16, 19:04

  8. Gerrit merged patch set 1 03/04/16, 19:04

  9. Christian Kuhn commented on patch set 2 03/04/16, 19:05

    Cherry Picked This patchset was cherry picked to branch TYPO3_7-6 as commit 16ff344b4cd5a02dca026000bb97060fe5174ef2