Breaking: #105920 - Folder->getSubFolder() throws FolderDoesNotExistException
See forge#105920
Description
An exception handling detail within FAL/Resource handling has been changed: When
calling
get
on a
\TYPO3\
object, and if this sub folder does not exist, the specific
\TYPO3\
is now raised
instead of the global
\Invalid
.
Impact
The change may have impact on extensions that directly or indirectly call
Folder->get
and expect a
\Invalid
to be thrown.
Affected installations
Folder
does not extend
\Invalid
.
Code that currently expects a
\Invalid
to be thrown, needs
adaption.
Migration
The change is breaking for code that takes an "optimistic" approach like "get the sub folder object, and if this throws, create one". Example:
try {
$mySubFolder = $myFolder->getSubFolder('mySubFolder');
} catch (\InvalidArgumentException) {
$mySubFolder = $myFolder->createFolder('mySubFolder');
}
This should be changed to catch a
Folder
instead:
Extensions that need to stay compatible with both TYPO3 v13 and v14 should catch
both exceptions and should later avoid catching
\Invalid
when v13 compatibility is dropped: