Bug #92790

PostFolderRenameSignal has wrong argument in TYPO3 v9

Added by Xavier Perseguers 25 days ago. Updated 12 days ago.

Status:
Resolved
Priority:
Must have
Category:
-
Target version:
Start date:
2020-11-07
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues

Related to TYPO3 Core - Bug #84539: SIGNAL_PostFolderRename BugClosed2018-03-27

Actions
#1

Updated by Gerrit Code Review 25 days ago

  • Status changed from New to Under Review

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66566

#2

Updated by Xavier Perseguers 25 days ago

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.

#3

Updated by Christian Kuhn 12 days ago

  • Related to Bug #84539: SIGNAL_PostFolderRename Bug added
#4

Updated by Gerrit Code Review 12 days ago

Patch set 2 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66566

#5

Updated by Gerrit Code Review 12 days ago

Patch set 3 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66566

#6

Updated by Xavier Perseguers 12 days ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF