2 namespace TYPO3\CMS\Core\Resource;
41 protected $table =
'sys_file_processedfile';
59 $this->databaseConnection =
$GLOBALS[
'TYPO3_DB'];
86 $originalFile = $this->resourceFactory->getFileObject((
int)$databaseRow[
'original']);
87 $originalFile->setStorage($this->resourceFactory->getStorageObject($originalFile->getProperty(
'storage')));
88 $taskType = $databaseRow[
'task_type'];
89 $configuration = unserialize($databaseRow[
'configuration']);
108 $processedFileObject = null;
109 if ($storage->
hasFile($identifier)) {
110 $databaseRow = $this->databaseConnection->exec_SELECTgetSingleRow(
113 'storage = ' . (
int)$storage->
getUid() .
114 ' AND identifier = ' . $this->databaseConnection->fullQuoteStr($identifier, $this->table)
120 return $processedFileObject;
128 public function add($processedFile)
130 if ($processedFile->isPersisted()) {
131 $this->
update($processedFile);
133 $insertFields = $processedFile->toArray();
134 $insertFields[
'crdate'] = $insertFields[
'tstamp'] = time();
136 $this->databaseConnection->exec_INSERTquery($this->table, $insertFields);
137 $uid = $this->databaseConnection->sql_insert_id();
138 $processedFile->updateProperties(array(
'uid' => $uid));
150 if ($processedFile->isPersisted()) {
151 $uid = (int)$processedFile->getUid();
153 $updateFields[
'tstamp'] = time();
154 $this->databaseConnection->exec_UPDATEquery($this->table,
'uid=' . (
int)$uid, $updateFields);
167 $databaseRow = $this->databaseConnection->exec_SELECTgetSingleRow(
170 'original=' . (
int)$file->getUid() .
171 ' AND task_type=' . $this->databaseConnection->fullQuoteStr($taskType, $this->table) .
172 ' AND configurationsha1=' . $this->databaseConnection->fullQuoteStr(sha1(serialize($configuration)), $this->table)
175 if (is_array($databaseRow)) {
180 return $processedFile;
190 if (!$file instanceof
File) {
191 throw new \InvalidArgumentException(
'Parameter is no File object but got type "'
192 . (is_object($file) ? get_class($file) : gettype($file)) .
'"', 1382006142);
194 $whereClause =
'original=' . (int)$file->getUid();
195 $rows = $this->databaseConnection->exec_SELECTgetRows(
'*', $this->table, $whereClause);
198 if ($rows !== null) {
199 foreach ($rows as $row) {
214 $res = $this->databaseConnection->exec_SELECTquery(
'*', $this->table,
'identifier <> \'\'');
217 while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
218 if ($storageUid && (
int)$storageUid !== (int)$row[
'storage']) {
223 $file->getStorage()->setEvaluatePermissions(
false);
227 'Failed to delete file "' . $row[
'identifier'] .
'" in storage uid ' . $row[
'storage'] .
'.',
236 $this->databaseConnection->exec_TRUNCATEquery($this->table);
251 return array_intersect_key($data, $this->databaseConnection->admin_get_fields($this->table));