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 #1

Updated by Markus Klein over 10 years ago

  • Assignee set to Steffen Ritter
  • Target version set to next-patchlevel
Actions #2

Updated by Marco Huber over 10 years ago

As a workaround I replaced $file->setContents($fileContent) with:

\TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_site . $file->getPublicUrl(), $fileContent, TRUE);
/** @var \TYPO3\CMS\Core\Resource\Service\IndexerService $indexerService */
$indexerService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService');
$indexerService->indexFile($file);

Actions #3

Updated by Marc Bastian Heinrichs over 10 years ago

  • Status changed from New to Needs Feedback
  • Assignee deleted (Steffen Ritter)

Was rather fixed in #49386 and should be in 6.1.5. Which version to you use?

Actions #4

Updated by Marco Huber over 10 years ago

Shame on me, on the development server I was still using 6.1.3, on live 6.1.5. After updating the development server everything is ok. So this issue can be closed.

Thank you Marc!

Actions #5

Updated by Alexander Opitz over 10 years ago

  • Status changed from Needs Feedback to Closed
  • Target version deleted (next-patchlevel)
Actions

Also available in: Atom PDF