Bug #92790
closed
PostFolderRenameSignal has wrong argument in TYPO3 v9
Added by Xavier Perseguers over 4 years ago.
Updated about 4 years ago.
Description
When renaming a folder two signals are sent:
- PreFolderRenameSignal
- PostFolderRenameSignal
Since TYPO3 v10 those signals (refactored as PSR-14) are correctly constructed, the "Pre" contains a reference to the Folder object before the renaming, the "Post" contains the Folder object after the renaming.
But in TYPO3 v9 (and for sure before as well), the "Post" signal still contains a reference to the Folder before the renaming, making this signal +/- totally useless.
This bug should have been spotted and fixed during the development of TYPO3 v10, while migrating to PSR-14.
- Status changed from New to Under Review
In case you need the correct behaviour until the fix is not merged, here is how you should work:
protected static $previousFolder;
/**
* @param Folder $folder
* @param string $newName
*/
public function preFolderRename(Folder $folder, string $newName): void
{
static::$previousFolder = $folder;
}
/**
* @param Folder $folder
* @param string $newName
*/
public function postFolderRename(Folder $folder, string $newName): void
{
if ($folder->getIdentifier() === static::$previousFolder->getIdentifier()) {
// This is a known bug: https://forge.typo3.org/issues/92790
$newIdentifier = dirname($folder->getIdentifier()) . '/' . $newName . '/';
$folder = $folder->getStorage()->getFolder($newIdentifier);
}
// your code here
}
Of course, if you know the bug is there (by testing the TYPO3 version), you can just compute the correct new $folder
without relying on the dynamic check.
- Related to Bug #84539: SIGNAL_PostFolderRename Bug added
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Status changed from Resolved to Closed
Also available in: Atom
PDF