Project

General

Profile

Actions

Bug #53622

closed

Updating the file content fails with the FAL API

Added by Marco Huber over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2013-11-13
Due date:
% Done:

0%

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

Description

Creating/Updating files with the FAL API fails because FAL want's to update a field sys_file.mimetype. But the field is called sys_file.mime_type in the database.

To reproduce:

/** @var \TYPO3\CMS\Core\Resource\StorageRepository $storageRepository */
$storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
/** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storage */
$storage = $storageRepository->findByUid(1);

//Create a file (or get an existing one, that makes no difference):
/** @var \TYPO3\CMS\Core\Resource\Folder $folder */
$folder = $storage->getFolder('/user_upload/');
$fileName = '123.txt';
$file = $storage->createFile($fileName, $folder); //A new record in sys_file is created and the file is created in the filesystem.

//Update the file
$fileContent = '12345filecontent';
$file->setContents($fileContent); //The file's content in the filesystem get's updated. But the mimetype changes and can not be updated in the database.
//this one throws the same error: $storage->setFileContents($file, $fileContent);

The error:

exec_UPDATEquery
caller: TYPO3\CMS\Core\Database\DatabaseConnection::exec_UPDATEquery
ERROR: Unknown column 'mimetype' in 'field list'
lastBuiltQuery: UPDATE sys_file SET mimetype='text/plain' WHERE uid=2071
debug_backtrace:
include(ysext/extbase/Scripts/CommandLineLauncher.php),li_dispatch.phpsh#65 
TYPO3\CMS\Extbase\Core\Bootstrap->run#32 
TYPO3\CMS\Extbase\Core\Bootstrap->handleRequest#197 
TYPO3\CMS\Extbase\Mvc\Cli\RequestHandler->handleRequest#208 
TYPO3\CMS\Extbase\Mvc\Dispatcher->dispatch#96 
TYPO3\CMS\Extbase\Mvc\Controller\CommandController->processRequest#100 
TYPO3\CMS\Extbase\Mvc\Controller\CommandController->callCommandMethod#114 
call_user_func_array#212 
BGM\MyExt\Command\MyCommandController->createFileCommand# 
TYPO3\CMS\Core\Resource\File->setContents#84 
TYPO3\CMS\Core\Resource\ResourceStorage->setFileContents#140 
TYPO3\CMS\Core\Resource\FileRepository->update#952 
TYPO3\CMS\Core\Database\DatabaseConnection->exec_UPDATEquery#263 
TYPO3\CMS\Core\Database\DatabaseConnection->debug#247

The problem is $file->setContents which calls TYPO3\CMS\Core\Resource\FileRepository->update, but I have no idea how to fix this.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #49386: ResourceStorage::setFileContents does not properly translate file info propertiesClosed2013-06-24

Actions
Actions

Also available in: Atom PDF