#97610Remove option to call \TYPO3\CMS\Core\Resource\Folder->getFiles() with $filterMode=false
Description
\TYPO3\CMS\Core\Resource\Folder->getFiles() has several parameters, the third one is $filterMode:
public function getFiles($start = 0, $numberOfItems = 0, $filterMode = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $recursive = false, $sort = '', $sortRev = false)
{
// Fallback for compatibility with the old method signature variable $useFilters that was used instead of $filterMode
if ($filterMode === false) {
$useFilters = false;
$backedUpFilters = [];
} else {
[$backedUpFilters, $useFilters] = $this->prepareFiltersInStorage($filterMode);
}
In TYPO3 6.0 in change 15405: [BUGFIX] Folder: File list filtering does not work the signature of the methoed was changed from
@public function getFiles($start = 0, $numberOfItems = 0, $useFilters = TRUE) {public function getFiles($start = 0, $numberOfItems = 0, $filterMode = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS) {@
to
It introduced the filter mode constants by renaming the third argument from $useFilters = TRUE to $filterMode = self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
The logic is meant to do the following: In case of self::FILTER_MODE_USE_OWN_FILTERS and self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS the filtering in the folder for this Folder->getFiles() call is not only done by the filters existing in the storage, but additionally those in the Folder. For the actual filtering to happen in the storage the storage->fileAndFolderNameFilters must be changed. In order to be able to restore the former state the previous filters are saved in $backedUpFilters to restore them after the operation.
The change 23398: [BUGFIX] File identifiers are case-insensitive included in TYPO3 6.2 set $backedUpFilters = []; if $filterMode === false. This was a massive change in another scope, and it looks like the author just wanted $backedUpFilters to be set as well in the if as the else case and initialized it in the wrong way.
$filterMode = self::FILTER_MODE_NO_FILTERS will set $backedUpFilters = null;
@$filterMode = false@ will set $backedUpFilters = [];
As restoreBackedUpFiltersInStorage() only continues if $backedUpFilters !== null there is a difference between these seemingly equal filtermodes: $filterMode = false will “reset” the $storage->fileAndFolderNameFilters to an empty array while $filterMode = self::FILTER_MODE_NO_FILTERS will not change $storage->fileAndFolderNameFilters at all.
This means $filterMode = false will reset the $storage->fileAndFolderNameFilters to an empty array permanently even if the storage contained filters before. I guess this is a bug. As 23398 was part of TYPO3 6.2 the core did not use the fallback itself back then and this bug went by unnoticed.
Long story short: This fallback is very outdated and even buggy, it should definitely be removed.
Whether breaking immediately or with deprecation I can’t decide, but I vote remove it
Reviews 2
History 13
-
Gerrit Code Review pushed patch set 1 for main to change 95879 status
NewUnder Review 09/16/26, 15:17 -
Gerrit Code Review pushed patch set 1 for 14.3 to change 96123 09/28/26, 10:11
-
Georg Ringer commented and changed status
Under ReviewResolved done0 %100 % 09/28/26, 10:15
Applied in changeset commit:4a351fbf80fbb5cbcfe591c1432c2ad5a42a62c2.