Bug #56084
closed
t3editor is not usable any more
Added by Alexander Schnitzler over 10 years ago.
Updated almost 7 years ago.
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.
- Assignee changed from Alexander Opitz to Alexander Schnitzler
- Assignee changed from Alexander Schnitzler to Frans Saris
Frans, can you please have a look at it?
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?
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?
- Status changed from Accepted to Under Review
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.
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.
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Status changed from Resolved to Closed
Also available in: Atom
PDF