get_filenames() is a resource hog and it gets worst and worst the bigger the
files directory gets. It's one of those functions in the core that eventually
cause crashes. Unless the importing functionality is totally rebuild with
pagination (etc) this can't be helped, but the function could be optimized to
reduce its hunger.
Few thing about the function:
* Generates four massive arrays. The bigger the directories and DB, the bigger
the arrays. Out of these arrays only one can be cleaned by garbage collector,
the rest are referenced till the end. Two of these arrays are unnecessary.
* Uses a lot of time in sorting and comparing. PHP's glob actual does its own
additional sorting if not told otherwise. On large results sets this takes
seconds, the implementation being equivalent to sort().
* Tries to files/directories without read access.
* Changes current working directory. It should change it back after reading.
Original issue reported on code.google.com by jukka.m.svahn on 24 Feb 2013 at 1:36
Original issue reported on code.google.com by
jukka.m.svahn
on 24 Feb 2013 at 1:36