Project

General

Profile

Actions

Bug #56084

closed

t3editor is not usable any more

Added by Alexander Schnitzler about 10 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
t3editor
Target version:
Start date:
2014-02-18
Due date:
% Done:

100%

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

Description

Regression has been introduced in #55371

The actual problem of the change is the following:

-            $ajaxObj->addContent('result', $this->fileData);
+            $fileData = array();
+            foreach ($this->fileData as $action => $result) {
+                foreach ($result as $files) {
+                    /** @var $file \TYPO3\CMS\Core\Resource\File */
+                    foreach ($files as $file) {
+                        $fileData[$action][] = $file->toArray();
+                    }
+                }
+            }
+            $ajaxObj->addContent('result', $fileData);

Don't know what that should have fixed as there is not a single unit test for the change but if you save a file edited with t3editor in the list module, $this->fileData is as such:

array(
  'editfile' => array(
    0 => true
  )
)

This results in $files being true instead of array in the second foreach loop. So the third foreach loop will not be executed and therefore $fileData is an empty array.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #55371: Ajax handler TYPO3_tcefile::process is brokenClosedFrans Saris2014-01-27

Actions
Blocks TYPO3 Core - Task #55515: Add CSRF Protection for tce_file.phpClosedAlexander Schnitzler2014-01-31

Actions
Actions #1

Updated by Alexander Opitz about 10 years ago

  • Assignee changed from Alexander Opitz to Alexander Schnitzler
Actions #2

Updated by Alexander Schnitzler about 10 years ago

  • Assignee changed from Alexander Schnitzler to Frans Saris

Frans, can you please have a look at it?

Actions #3

Updated by Frans Saris about 10 years ago

Hi Alexander,

            $fileData = array();
            foreach ($this->fileData as $action => $result) {
                if ($action === 'upload') {
                    foreach ($result as $files) {
                        /** @var $file \TYPO3\CMS\Core\Resource\File */
                        foreach ($files as $file) {
                            $fileData[$action][] = array_merge(
                                $file->toArray(),
                                array (
                                    'date' => BackendUtility::date($file->getModificationTime()),
                                    'iconClasses' => \TYPO3\CMS\Backend\Utility\IconUtility::mapFileExtensionToSpriteIconClass($file->getExtension()),
                                )
                            );
                        }
                    }
                } else {
                    $fileData[$action] = $result;
                }
            }
            $ajaxObj->addContent('result', $fileData);

This fixes the problem.
But I'm not sure if there are more 'actions' that return File objects like upload. When I made this change I search for other uses of the ajax api but couldn't find any. Do you know if there are more?

Actions #4

Updated by Alexander Schnitzler about 10 years ago

Thanks but that really feels wrong. An API should be consistent and clear and not handle several different cases with if, else, and multiple foreach loops.

Let's dig into it and find out where these calls are used and what for. What do you think?

Actions #5

Updated by Gerrit Code Review about 10 years ago

  • Status changed from Accepted to Under Review

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

Actions #6

Updated by Frans Saris about 10 years ago

The result set can have multiple results.

[delete][] = boolean
[copy][] = File | Folder
[move][] = File | Folder
[rename][] = File | Folder
[newfolder][] = Folder
[newfile][] = File
[editfile][] = boolean
[upload][][] = File
[unzip][] = boolean

I have changed the processAjaxRequest() so it loops through the result set and flattens the possible values.

Actions #7

Updated by Gerrit Code Review about 10 years ago

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

Actions #8

Updated by Gerrit Code Review about 10 years ago

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

Actions #9

Updated by Gerrit Code Review about 10 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27739

Actions #10

Updated by Gerrit Code Review about 10 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27739

Actions #11

Updated by Markus Klein about 10 years ago

I don't get the problem. I can edit text files as usual in the filelist module.

Edit: Got the problem. It's about the Save button.

Actions #12

Updated by Gerrit Code Review about 10 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27739

Actions #13

Updated by Gerrit Code Review about 10 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27739

Actions #14

Updated by Gerrit Code Review about 10 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27739

Actions #15

Updated by Gerrit Code Review about 10 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27739

Actions #16

Updated by Gerrit Code Review about 10 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27739

Actions #17

Updated by Gerrit Code Review about 10 years ago

Patch set 1 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27863

Actions #18

Updated by Frans Saris about 10 years ago

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

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF