Project

General

Profile

Actions

Bug #92790

closed

PostFolderRenameSignal has wrong argument in TYPO3 v9

Added by Xavier Perseguers over 3 years ago. Updated over 3 years ago.

Status:
Closed
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 1 (0 open1 closed)

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

Actions
Actions #1

Updated by Gerrit Code Review over 3 years 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

Actions #2

Updated by Xavier Perseguers over 3 years 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.

Actions #3

Updated by Christian Kuhn over 3 years ago

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

Updated by Gerrit Code Review over 3 years 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

Actions #5

Updated by Gerrit Code Review over 3 years 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

Actions #6

Updated by Xavier Perseguers over 3 years ago

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

Updated by Benni Mack over 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF