[BUGFIX] Fix error in filelist after deleting file with broken refs
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Utility / File / ExtendedFileUtility.php
1 <?php
2 namespace TYPO3\CMS\Core\Utility\File;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Backend\Utility\IconUtility;
19 use TYPO3\CMS\Core\Messaging\FlashMessage;
20 use TYPO3\CMS\Core\Messaging\FlashMessageService;
21 use TYPO3\CMS\Core\Resource\File;
22 use TYPO3\CMS\Core\Resource\Folder;
23 use TYPO3\CMS\Core\Resource\ResourceFactory;
24 use TYPO3\CMS\Core\Resource\ResourceStorage;
25 use TYPO3\CMS\Core\Utility\CommandUtility;
26 use TYPO3\CMS\Core\Utility\GeneralUtility;
27 use TYPO3\CMS\Core\Utility\PathUtility;
28
29 /**
30 * Contains functions for performing file operations like copying, pasting, uploading, moving,
31 * deleting etc. through the TCE
32 *
33 * See document "TYPO3 Core API" for syntax
34 *
35 * This class contains functions primarily used by tce_file.php (TYPO3 Core Engine for file manipulation)
36 * Functions include copying, moving, deleting, uploading and so on...
37 *
38 * Important internal variables:
39 *
40 * $filemounts (see basicFileFunctions)
41 * $f_ext (see basicFileFunctions)
42 *
43 * All fileoperations must be within the filemount-paths. Further the fileextension
44 * MUST validate TRUE with the f_ext array
45 *
46 * The unzip-function allows unzip only if the destination path has it's f_ext[]['allow'] set to '*'!!
47 * You are allowed to copy/move folders within the same 'space' (web/ftp).
48 * You are allowed to copy/move folders between spaces (web/ftp) IF the destination has it's f_ext[]['allow'] set to '*'!
49 *
50 * Advice:
51 * You should always exclude php-files from the webspace. This will keep people from uploading, copy/moving and renaming files to become executable php scripts.
52 * You should never mount a ftp_space 'below' the webspace so that it reaches into the webspace. This is because if somebody unzips a zip-file in the ftp-space so that it reaches out into the webspace this will be a violation of the safety
53 * For example this is a bad idea: you have an ftp-space that is '/www/' and a web-space that is '/www/htdocs/'
54 *
55 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
56 */
57 class ExtendedFileUtility extends BasicFileUtility {
58
59 /**
60 * External static variables:
61 * Notice; some of these are overridden in the start() method with values from $GLOBALS['TYPO3_CONF_VARS']['BE']
62 * Path to unzip-program (with trailing '/')
63 *
64 * @var string
65 */
66 public $unzipPath = '';
67
68 /**
69 * If set, the uploaded files will overwrite existing files.
70 *
71 * @var bool
72 */
73 public $dontCheckForUnique = 0;
74
75 /**
76 * This array is self-explaining (look in the class below).
77 * It grants access to the functions. This could be set from outside in order to enabled functions to users.
78 * See also the function setActionPermissions() which takes input directly from the user-record
79 *
80 * @var array
81 */
82 public $actionPerms = array(
83 // File permissions
84 'addFile' => FALSE,
85 'readFile' => FALSE,
86 'writeFile' => FALSE,
87 'copyFile' => FALSE,
88 'moveFile' => FALSE,
89 'renameFile' => FALSE,
90 'unzipFile' => FALSE,
91 'deleteFile' => FALSE,
92 // Folder permissions
93 'addFolder' => FALSE,
94 'readFolder' => FALSE,
95 'writeFolder' => FALSE,
96 'copyFolder' => FALSE,
97 'moveFolder' => FALSE,
98 'renameFolder' => FALSE,
99 'deleteFolder' => FALSE,
100 'recursivedeleteFolder' => FALSE
101 );
102
103 /**
104 * This is regarded to be the recycler folder
105 *
106 * @var string
107 */
108 public $recyclerFN = '_recycler_';
109
110 /**
111 * Will contain map between upload ID and the final filename
112 *
113 * @var array
114 */
115 public $internalUploadMap = array();
116
117 /**
118 * @var string
119 */
120 public $lastError = '';
121
122 /**
123 * All error messages from the file operations of this script instance
124 *
125 * @var array
126 */
127 protected $errorMessages = array();
128
129 /**
130 * @var array
131 */
132 protected $fileCmdMap;
133
134 /**
135 * The File Factory
136 *
137 * @var \TYPO3\CMS\Core\Resource\ResourceFactory
138 */
139 protected $fileFactory;
140
141 /**
142 * Initialization of the class
143 *
144 * @param array $fileCmds Array with the commands to execute. See "TYPO3 Core API" document
145 * @return void
146 */
147 public function start($fileCmds) {
148 $unzipPath = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path']);
149 if (substr($unzipPath, -1) !== '/' && is_dir($unzipPath)) {
150 // Make sure the path ends with a slash
151 $unzipPath .= '/';
152 }
153 $this->unzipPath = $unzipPath;
154 // Initialize Object Factory
155 $this->fileFactory = ResourceFactory::getInstance();
156 // Initializing file processing commands:
157 $this->fileCmdMap = $fileCmds;
158 }
159
160 /**
161 * Sets the file action permissions.
162 * If no argument is given, permissions of the currently logged in backend user are taken into account.
163 *
164 * @param array $permissions File Permissions.
165 */
166 public function setActionPermissions(array $permissions = array()) {
167 if (empty($permissions)) {
168 $permissions = $GLOBALS['BE_USER']->getFilePermissions();
169 }
170 $this->actionPerms = $permissions;
171 }
172
173 /**
174 * Processing the command array in $this->fileCmdMap
175 *
176 * @return mixed FALSE, if the file functions were not initialized
177 * @throws \UnexpectedValueException
178 */
179 public function processData() {
180 $result = array();
181 if (!$this->isInit) {
182 return FALSE;
183 }
184 if (is_array($this->fileCmdMap)) {
185 // Check if there were uploads expected, but no one made
186 if ($this->fileCmdMap['upload']) {
187 $uploads = $this->fileCmdMap['upload'];
188 foreach ($uploads as $upload) {
189 if (empty($_FILES[('upload_' . $upload['data'])]['name'])
190 || (is_array($_FILES[('upload_' . $upload['data'])]['name'])
191 && empty($_FILES[('upload_' . $upload['data'])]['name'][0])
192 )
193 ) {
194 unset($this->fileCmdMap['upload'][$upload['data']]);
195 }
196 }
197 if (count($this->fileCmdMap['upload']) == 0) {
198 $this->writelog(1, 1, 108, 'No file was uploaded!', '');
199 }
200 }
201
202 // Check if there were new folder names expected, but non given
203 if ($this->fileCmdMap['newfolder']) {
204 foreach ($this->fileCmdMap['newfolder'] as $key => $cmdArr) {
205 if (empty($cmdArr['data'])) {
206 unset($this->fileCmdMap['newfolder'][$key]);
207 }
208 }
209 if (count($this->fileCmdMap['newfolder']) === 0) {
210 $this->writeLog(6, 1, 108, 'No name for new folder given!', '');
211 }
212 }
213
214 // Traverse each set of actions
215 foreach ($this->fileCmdMap as $action => $actionData) {
216 // Traverse all action data. More than one file might be affected at the same time.
217 if (is_array($actionData)) {
218 $result[$action] = array();
219 foreach ($actionData as $cmdArr) {
220 // Clear file stats
221 clearstatcache();
222 // Branch out based on command:
223 switch ($action) {
224 case 'delete':
225 $result[$action][] = $this->func_delete($cmdArr);
226 break;
227 case 'copy':
228 $result[$action][] = $this->func_copy($cmdArr);
229 break;
230 case 'move':
231 $result[$action][] = $this->func_move($cmdArr);
232 break;
233 case 'rename':
234 $result[$action][] = $this->func_rename($cmdArr);
235 break;
236 case 'newfolder':
237 $result[$action][] = $this->func_newfolder($cmdArr);
238 break;
239 case 'newfile':
240 $result[$action][] = $this->func_newfile($cmdArr);
241 break;
242 case 'editfile':
243 $result[$action][] = $this->func_edit($cmdArr);
244 break;
245 case 'upload':
246 $result[$action][] = $this->func_upload($cmdArr);
247 break;
248 case 'unzip':
249 $result[$action][] = $this->func_unzip($cmdArr);
250 break;
251 }
252 // Hook for post-processing the action
253 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_extfilefunc.php']['processData'])) {
254 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_extfilefunc.php']['processData'] as $classRef) {
255 $hookObject = GeneralUtility::getUserObj($classRef);
256 if (!$hookObject instanceof ExtendedFileUtilityProcessDataHookInterface) {
257 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Utility\\File\\ExtendedFileUtilityProcessDataHookInterface', 1279719168);
258 }
259 $hookObject->processData_postProcessAction($action, $cmdArr, $result[$action], $this);
260 }
261 }
262 }
263 }
264 }
265 }
266 return $result;
267 }
268
269 /**
270 * Adds all log error messages from the operations of this script instance to the FlashMessageQueue
271 *
272 * @return void
273 */
274 public function pushErrorMessagesToFlashMessageQueue() {
275 foreach ($this->getErrorMessages() as $msg) {
276 $flashMessage = GeneralUtility::makeInstance(
277 FlashMessage::class,
278 $msg,
279 '',
280 FlashMessage::ERROR,
281 TRUE
282 );
283 $this->addFlashMessage($flashMessage);
284 }
285 }
286
287 /**
288 * Return all error messages from the file operations of this script instance
289 *
290 * @return array all errorMessages as a numerical array
291 */
292 public function getErrorMessages() {
293 return $this->errorMessages;
294 }
295
296 /**
297 * @param int $action The action number. See the functions in the class for a hint. Eg. edit is '9', upload is '1' ...
298 * @param int $error The severity: 0 = message, 1 = error, 2 = System Error, 3 = security notice (admin)
299 * @param int $details_nr This number is unique for every combination of $type and $action. This is the error-message number, which can later be used to translate error messages.
300 * @param string $details This is the default, raw error message in english
301 * @param array $data Array with special information that may go into $details by "%s" marks / sprintf() when the log is shown
302 * @return void
303 */
304 public function writeLog($action, $error, $details_nr, $details, $data) {
305 // Type value for tce_file.php
306 $type = 2;
307 if (is_object($this->getBackendUser())) {
308 $this->getBackendUser()->writelog($type, $action, $error, $details_nr, $details, $data);
309 }
310 if ($error > 0) {
311 $this->lastError = vsprintf($details, $data);
312 $this->errorMessages[] = $this->lastError;
313 }
314 }
315
316 /*************************************
317 *
318 * File operation functions
319 *
320 **************************************/
321 /**
322 * Deleting files and folders (action=4)
323 *
324 * @param array $cmds $cmds['data'] is the file/folder to delete
325 * @return bool Returns TRUE upon success
326 */
327 public function func_delete($cmds) {
328 $result = FALSE;
329 if (!$this->isInit) {
330 return $result;
331 }
332 // Example indentifier for $cmds['data'] => "4:mypath/tomyfolder/myfile.jpg"
333 // for backwards compatibility: the combined file identifier was the path+filename
334 $fileObject = $this->getFileObject($cmds['data']);
335 // @todo implement the recycler feature which has been removed from the original implementation
336 // checks to delete the file
337 if ($fileObject instanceof File) {
338 // check if the file still has references
339 // Exclude sys_file_metadata records as these are no use references
340 $refIndexRecords = $this->getDatabaseConnection()->exec_SELECTgetRows(
341 '*',
342 'sys_refindex',
343 'deleted=0 AND ref_table="sys_file" AND ref_uid=' . (int)$fileObject->getUid()
344 . ' AND tablename != "sys_file_metadata"'
345 );
346 $deleteFile = TRUE;
347 if (count($refIndexRecords) > 0) {
348 $shortcutContent = array();
349 $brokenReferences = array();
350
351 foreach ($refIndexRecords as $fileReferenceRow) {
352 if ($fileReferenceRow['tablename'] === 'sys_file_reference') {
353 $row = $this->transformFileReferenceToRecordReference($fileReferenceRow);
354 $shortcutRecord = BackendUtility::getRecord($row['tablename'], $row['recuid']);
355
356 if ($shortcutRecord) {
357 $icon = IconUtility::getSpriteIconForRecord($row['tablename'], $shortcutRecord);
358 $icon = '<a href="#" class="t3-js-clickmenutrigger" data-table="' . $row['tablename'] . '" data-uid="' . $row['recuid'] . '" data-listframe="1" data-iteminfo="%2Binfo,history,edit">' . $icon . '</a>';
359 $shortcutContent[] = $icon . htmlspecialchars((BackendUtility::getRecordTitle($row['tablename'], $shortcutRecord) . ' [' . BackendUtility::getRecordPath($shortcutRecord['pid'], '', 80) . ']'));
360 } else {
361 $brokenReferences[] = $fileReferenceRow['ref_uid'];
362 }
363 }
364 }
365 if (!empty($brokenReferences)) {
366 // render a message that the file has broken references
367 $flashMessage = GeneralUtility::makeInstance(
368 FlashMessage::class,
369 sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileHasBrokenReferences'), count($brokenReferences)),
370 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileHasBrokenReferences'),
371 FlashMessage::INFO,
372 TRUE
373 );
374 $this->addFlashMessage($flashMessage);
375 }
376 if (!empty($shortcutContent)) {
377 // render a message that the file could not be deleted
378 $flashMessage = GeneralUtility::makeInstance(
379 FlashMessage::class,
380 sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) . '<br />' . implode('<br />', $shortcutContent),
381 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
382 FlashMessage::WARNING,
383 TRUE
384 );
385 $this->addFlashMessage($flashMessage);
386 $deleteFile = FALSE;
387 }
388 }
389
390 if ($deleteFile) {
391 try {
392 $result = $fileObject->delete();
393
394 // show the user that the file was deleted
395 $flashMessage = GeneralUtility::makeInstance(
396 FlashMessage::class,
397 sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
398 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileDeleted'),
399 FlashMessage::OK,
400 TRUE
401 );
402 $this->addFlashMessage($flashMessage);
403 // Log success
404 $this->writelog(4, 0, 1, 'File "%s" deleted', array($fileObject->getIdentifier()));
405 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
406 $this->writelog(4, 1, 112, 'You are not allowed to access the file', array($fileObject->getIdentifier()));
407 } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
408 $this->writelog(4, 1, 111, 'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
409 } catch (\RuntimeException $e) {
410 $this->writelog(4, 1, 110, 'Could not delete file "%s". Write-permission problem?', array($fileObject->getIdentifier()));
411 }
412 }
413 } else {
414 try {
415 /** @var \TYPO3\CMS\Core\Resource\Folder $fileObject */
416 $result = $fileObject->delete(TRUE);
417 if ($result) {
418 // notify the user that the folder was deleted
419 /** @var FlashMessage $flashMessage */
420 $flashMessage = GeneralUtility::makeInstance(
421 FlashMessage::class,
422 sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.folderDeleted'), $fileObject->getName()),
423 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.folderDeleted'),
424 FlashMessage::OK,
425 TRUE
426 );
427 $this->addFlashMessage($flashMessage);
428 // Log success
429 $this->writelog(4, 0, 3, 'Directory "%s" deleted', array($fileObject->getIdentifier()));
430 }
431 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
432 $this->writelog(4, 1, 120, 'Could not delete directory! Is directory "%s" empty? (You are not allowed to delete directories recursively).', array($fileObject->getIdentifier()));
433 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException $e) {
434 $this->writelog(4, 1, 123, 'You are not allowed to access the directory', array($fileObject->getIdentifier()));
435 } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
436 $this->writelog(4, 1, 121, 'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
437 } catch (\TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException $e) {
438 $this->writelog(4, 1, 120, 'Could not delete directory "%s"! Write-permission problem?', array($fileObject->getIdentifier()));
439 }
440 }
441 return $result;
442 }
443
444 /**
445 * Maps results from the fal file reference table on the
446 * structure of the normal reference index table.
447 *
448 * @param array $referenceRecord
449 * @return array
450 */
451 protected function transformFileReferenceToRecordReference(array $referenceRecord) {
452 $fileReference = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
453 '*',
454 'sys_file_reference',
455 'uid=' . (int)$referenceRecord['recuid']
456 );
457 return array(
458 'recuid' => $fileReference['uid_foreign'],
459 'tablename' => $fileReference['tablenames'],
460 'field' => $fileReference['fieldname'],
461 'flexpointer' => '',
462 'softref_key' => '',
463 'sorting' => $fileReference['sorting_foreign']
464 );
465 }
466
467 /**
468 * Gets a File or a Folder object from an identifier [storage]:[fileId]
469 *
470 * @param string $identifier
471 * @return \TYPO3\CMS\Core\Resource\Folder|\TYPO3\CMS\Core\Resource\File
472 * @throws \TYPO3\CMS\Core\Resource\Exception\InvalidFileException
473 */
474 protected function getFileObject($identifier) {
475 $object = $this->fileFactory->retrieveFileOrFolderObject($identifier);
476 if (!is_object($object)) {
477 throw new \TYPO3\CMS\Core\Resource\Exception\InvalidFileException('The item ' . $identifier . ' was not a file or directory!!', 1320122453);
478 }
479 if ($object->getStorage()->getUid() === 0) {
480 throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889830);
481 }
482 return $object;
483 }
484
485 /**
486 * Copying files and folders (action=2)
487 *
488 * $cmds['data'] (string): The file/folder to copy
489 * + example "4:mypath/tomyfolder/myfile.jpg")
490 * + for backwards compatibility: the identifier was the path+filename
491 * $cmds['target'] (string): The path where to copy to.
492 * + example "2:targetpath/targetfolder/"
493 * $cmds['altName'] (string): Use an alternative name if the target already exists
494 *
495 * @param array $cmds Command details as described above
496 * @return \TYPO3\CMS\Core\Resource\File
497 */
498 protected function func_copy($cmds) {
499 if (!$this->isInit) {
500 return FALSE;
501 }
502 $sourceFileObject = $this->getFileObject($cmds['data']);
503 /** @var $targetFolderObject \TYPO3\CMS\Core\Resource\Folder */
504 $targetFolderObject = $this->getFileObject($cmds['target']);
505 // Basic check
506 if (!$targetFolderObject instanceof Folder) {
507 $this->writelog(2, 2, 100, 'Destination "%s" was not a directory', array($cmds['target']));
508 return FALSE;
509 }
510 // If this is TRUE, we append _XX to the file name if
511 $appendSuffixOnConflict = (string)$cmds['altName'];
512 $resultObject = NULL;
513 // Copying the file
514 if ($sourceFileObject instanceof File) {
515 try {
516 $conflictMode = $appendSuffixOnConflict !== '' ? 'renameNewFile' : 'cancel';
517 $resultObject = $sourceFileObject->copyTo($targetFolderObject, NULL, $conflictMode);
518 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
519 $this->writelog(2, 1, 114, 'You are not allowed to copy files', '');
520 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
521 $this->writelog(2, 1, 110, 'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
522 } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
523 $this->writelog(2, 1, 111, 'Extension of file name "%s" is not allowed in "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
524 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException $e) {
525 $this->writelog(2, 1, 112, 'File "%s" already exists in folder "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
526 } catch (\BadMethodCallException $e) {
527 $this->writelog(3, 1, 128, 'The function to copy a file between storages is not yet implemented', array());
528 } catch (\RuntimeException $e) {
529 $this->writelog(2, 2, 109, 'File "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
530 }
531 if ($resultObject) {
532 $this->writelog(2, 0, 1, 'File "%s" copied to "%s"', array($sourceFileObject->getIdentifier(), $resultObject->getIdentifier()));
533 }
534 } else {
535 // Else means this is a Folder
536 $sourceFolderObject = $sourceFileObject;
537 try {
538 $conflictMode = $appendSuffixOnConflict !== '' ? 'renameNewFile' : 'cancel';
539 $resultObject = $sourceFolderObject->copyTo($targetFolderObject, NULL, $conflictMode);
540 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
541 $this->writelog(2, 1, 125, 'You are not allowed to copy directories', '');
542 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
543 $this->writelog(2, 1, 110, 'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
544 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException $e) {
545 $this->writelog(2, 1, 121, 'You don\'t have full access to the destination directory "%s"!', array($targetFolderObject->getIdentifier()));
546 } catch (\TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException $e) {
547 $this->writelog(2, 1, 122, 'Destination cannot be inside the target! D="%s", T="%s"', array($targetFolderObject->getIdentifier(), $sourceFolderObject->getIdentifier()));
548 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException $e) {
549 $this->writelog(2, 1, 123, 'Target "%s" already exists!', array($targetFolderObject->getIdentifier()));
550 } catch (\BadMethodCallException $e) {
551 $this->writelog(3, 1, 129, 'The function to copy a folder between storages is not yet implemented', array());
552 } catch (\RuntimeException $e) {
553 $this->writelog(2, 2, 119, 'Directory "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
554 }
555 if ($resultObject) {
556 $this->writelog(2, 0, 2, 'Directory "%s" copied to "%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
557 }
558 }
559 return $resultObject;
560 }
561
562 /**
563 * Moving files and folders (action=3)
564 *
565 * $cmds['data'] (string): The file/folder to move
566 * + example "4:mypath/tomyfolder/myfile.jpg")
567 * + for backwards compatibility: the identifier was the path+filename
568 * $cmds['target'] (string): The path where to move to.
569 * + example "2:targetpath/targetfolder/"
570 * $cmds['altName'] (string): Use an alternative name if the target already exists
571 *
572 * @param array $cmds Command details as described above
573 * @return \TYPO3\CMS\Core\Resource\File
574 */
575 protected function func_move($cmds) {
576 if (!$this->isInit) {
577 return FALSE;
578 }
579 $sourceFileObject = $this->getFileObject($cmds['data']);
580 $targetFolderObject = $this->getFileObject($cmds['target']);
581 // Basic check
582 if (!$targetFolderObject instanceof Folder) {
583 $this->writelog(3, 2, 100, 'Destination "%s" was not a directory', array($cmds['target']));
584 return FALSE;
585 }
586 $alternativeName = (string)$cmds['altName'];
587 $resultObject = NULL;
588 // Moving the file
589 if ($sourceFileObject instanceof File) {
590 try {
591 if ($alternativeName !== '') {
592 // Don't allow overwriting existing files, but find a new name
593 $resultObject = $sourceFileObject->moveTo($targetFolderObject, $alternativeName, 'renameNewFile');
594 } else {
595 // Don't allow overwriting existing files
596 $resultObject = $sourceFileObject->moveTo($targetFolderObject, NULL, 'cancel');
597 }
598 $this->writelog(3, 0, 1, 'File "%s" moved to "%s"', array($sourceFileObject->getIdentifier(), $resultObject->getIdentifier()));
599 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
600 $this->writelog(3, 1, 114, 'You are not allowed to move files', '');
601 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
602 $this->writelog(3, 1, 110, 'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
603 } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
604 $this->writelog(3, 1, 111, 'Extension of file name "%s" is not allowed in "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
605 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException $e) {
606 $this->writelog(3, 1, 112, 'File "%s" already exists in folder "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
607 } catch (\BadMethodCallException $e) {
608 $this->writelog(3, 1, 126, 'The function to move a file between storages is not yet implemented', array());
609 } catch (\RuntimeException $e) {
610 $this->writelog(3, 2, 109, 'File "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
611 }
612 } else {
613 // Else means this is a Folder
614 $sourceFolderObject = $sourceFileObject;
615 try {
616 if ($alternativeName !== '') {
617 // Don't allow overwriting existing files, but find a new name
618 $resultObject = $sourceFolderObject->moveTo($targetFolderObject, $alternativeName, 'renameNewFile');
619 } else {
620 // Don't allow overwriting existing files
621 $resultObject = $sourceFolderObject->moveTo($targetFolderObject, NULL, 'renameNewFile');
622 }
623 $this->writelog(3, 0, 2, 'Directory "%s" moved to "%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
624 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
625 $this->writelog(3, 1, 125, 'You are not allowed to move directories', '');
626 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
627 $this->writelog(3, 1, 110, 'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
628 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException $e) {
629 $this->writelog(3, 1, 121, 'You don\'t have full access to the destination directory "%s"!', array($targetFolderObject->getIdentifier()));
630 } catch (\TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException $e) {
631 $this->writelog(3, 1, 122, 'Destination cannot be inside the target! D="%s", T="%s"', array($targetFolderObject->getIdentifier(), $sourceFolderObject->getIdentifier()));
632 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException $e) {
633 $this->writelog(3, 1, 123, 'Target "%s" already exists!', array($targetFolderObject->getIdentifier()));
634 } catch (\BadMethodCallException $e) {
635 $this->writelog(3, 1, 127, 'The function to move a folder between storages is not yet implemented', array());
636 } catch (\RuntimeException $e) {
637 $this->writelog(3, 2, 119, 'Directory "%s" WAS NOT moved to "%s"! Write-permission problem?', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
638 }
639 }
640 return $resultObject;
641 }
642
643 /**
644 * Renaming files or foldes (action=5)
645 *
646 * $cmds['data'] (string): The file/folder to copy
647 * + example "4:mypath/tomyfolder/myfile.jpg")
648 * + for backwards compatibility: the identifier was the path+filename
649 * $cmds['target'] (string): New name of the file/folder
650 *
651 * @param array $cmds Command details as described above
652 * @return \TYPO3\CMS\Core\Resource\File Returns the new file upon success
653 */
654 public function func_rename($cmds) {
655 if (!$this->isInit) {
656 return FALSE;
657 }
658 $sourceFileObject = $this->getFileObject($cmds['data']);
659 $targetFile = $cmds['target'];
660 $resultObject = NULL;
661 if ($sourceFileObject instanceof File) {
662 try {
663 // Try to rename the File
664 $resultObject = $sourceFileObject->rename($targetFile);
665 $this->writelog(5, 0, 1, 'File renamed from "%s" to "%s"', array($sourceFileObject->getName(), $targetFile));
666 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
667 $this->writelog(5, 1, 102, 'You are not allowed to rename files!', '');
668 } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
669 $this->writelog(5, 1, 101, 'Extension of file name "%s" or "%s" was not allowed!', array($sourceFileObject->getName(), $targetFile));
670 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException $e) {
671 $this->writelog(5, 1, 120, 'Destination "%s" existed already!', array($targetFile));
672 } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
673 $this->writelog(5, 1, 121, 'Destination path "%s" was not within your mountpoints!', array($targetFile));
674 } catch (\RuntimeException $e) {
675 $this->writelog(5, 1, 100, 'File "%s" was not renamed! Write-permission problem in "%s"?', array($sourceFileObject->getName(), $targetFile));
676 }
677 } else {
678 // Else means this is a Folder
679 try {
680 // Try to rename the Folder
681 $resultObject = $sourceFileObject->rename($targetFile);
682 $this->writelog(5, 0, 2, 'Directory renamed from "%s" to "%s"', array($sourceFileObject->getName(), $targetFile));
683 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
684 $this->writelog(5, 1, 111, 'You are not allowed to rename directories!', '');
685 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException $e) {
686 $this->writelog(5, 1, 120, 'Destination "%s" existed already!', array($targetFile));
687 } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
688 $this->writelog(5, 1, 121, 'Destination path "%s" was not within your mountpoints!', array($targetFile));
689 } catch (\RuntimeException $e) {
690 $this->writelog(5, 1, 110, 'Directory "%s" was not renamed! Write-permission problem in "%s"?', array($sourceFileObject->getName(), $targetFile));
691 }
692 }
693 return $resultObject;
694 }
695
696 /**
697 * This creates a new folder. (action=6)
698 *
699 * $cmds['data'] (string): The new folder name
700 * $cmds['target'] (string): The path where to copy to.
701 * + example "2:targetpath/targetfolder/"
702 *
703 * @param array $cmds Command details as described above
704 * @return \TYPO3\CMS\Core\Resource\Folder Returns the new foldername upon success
705 */
706 public function func_newfolder($cmds) {
707 if (!$this->isInit) {
708 return FALSE;
709 }
710 $targetFolderObject = $this->getFileObject($cmds['target']);
711 if (!$targetFolderObject instanceof Folder) {
712 $this->writelog(6, 2, 104, 'Destination "%s" was not a directory', array($cmds['target']));
713 return FALSE;
714 }
715 $resultObject = NULL;
716 try {
717 $folderName = $cmds['data'];
718 $resultObject = $targetFolderObject->createFolder($folderName);
719 $this->writelog(6, 0, 1, 'Directory "%s" created in "%s"', array($folderName, $targetFolderObject->getIdentifier() . '/'));
720 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException $e) {
721 $this->writelog(6, 1, 103, 'You are not allowed to create directories!', '');
722 } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
723 $this->writelog(6, 1, 102, 'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier() . '/'));
724 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException $e) {
725 $this->writelog(6, 1, 101, 'File or directory "%s" existed already!', array($folderName));
726 } catch (\RuntimeException $e) {
727 $this->writelog(6, 1, 100, 'Directory "%s" not created. Write-permission problem in "%s"?', array($folderName, $targetFolderObject->getIdentifier() . '/'));
728 }
729 return $resultObject;
730 }
731
732 /**
733 * This creates a new file. (action=8)
734 * $cmds['data'] (string): The new file name
735 * $cmds['target'] (string): The path where to create it.
736 * + example "2:targetpath/targetfolder/"
737 *
738 * @param array $cmds Command details as described above
739 * @return string Returns the new filename upon success
740 */
741 public function func_newfile($cmds) {
742 if (!$this->isInit) {
743 return FALSE;
744 }
745 $targetFolderObject = $this->getFileObject($cmds['target']);
746 if (!$targetFolderObject instanceof Folder) {
747 $this->writelog(8, 2, 104, 'Destination "%s" was not a directory', array($cmds['target']));
748 return FALSE;
749 }
750 $resultObject = NULL;
751 try {
752 $fileName = $cmds['data'];
753 $resultObject = $targetFolderObject->createFile($fileName);
754 $this->writelog(8, 0, 1, 'File created: "%s"', array($fileName));
755 } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
756 $this->writeLog(8, 1, 106, 'Extension of file "%s" was not allowed!', array($fileName));
757 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException $e) {
758 $this->writelog(8, 1, 103, 'You are not allowed to create files!', '');
759 } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
760 $this->writelog(8, 1, 102, 'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier()));
761 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException $e) {
762 $this->writelog(8, 1, 101, 'File existed already in "%s"!', array($targetFolderObject->getIdentifier()));
763 } catch (\TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException $e) {
764 $this->writelog(8, 1, 106, 'File name "%s" was not allowed!', $fileName);
765 } catch (\RuntimeException $e) {
766 $this->writelog(8, 1, 100, 'File "%s" was not created! Write-permission problem in "%s"?', array($fileName, $targetFolderObject->getIdentifier()));
767 }
768 return $resultObject;
769 }
770
771 /**
772 * Editing textfiles or folders (action=9)
773 *
774 * @param array $cmds $cmds['data'] is the new content. $cmds['target'] is the target (file or dir)
775 * @return bool Returns TRUE on success
776 */
777 public function func_edit($cmds) {
778 if (!$this->isInit) {
779 return FALSE;
780 }
781 // Example indentifier for $cmds['target'] => "4:mypath/tomyfolder/myfile.jpg"
782 // for backwards compatibility: the combined file identifier was the path+filename
783 $fileIdentifier = $cmds['target'];
784 $fileObject = $this->getFileObject($fileIdentifier);
785 // Example indentifier for $cmds['target'] => "2:targetpath/targetfolder/"
786 $content = $cmds['data'];
787 if (!$fileObject instanceof File) {
788 $this->writelog(9, 2, 123, 'Target "%s" was not a file!', array($fileIdentifier));
789 return FALSE;
790 }
791 $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
792 if (!GeneralUtility::inList($extList, $fileObject->getExtension())) {
793 $this->writelog(9, 1, 102, 'File extension "%s" is not a textfile format! (%s)', array($fileObject->getExtension(), $extList));
794 return FALSE;
795 }
796 try {
797 $fileObject->setContents($content);
798 clearstatcache();
799 $this->writelog(9, 0, 1, 'File saved to "%s", bytes: %s, MD5: %s ', array($fileObject->getIdentifier(), $fileObject->getSize(), md5($content)));
800 return TRUE;
801 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
802 $this->writelog(9, 1, 104, 'You are not allowed to edit files!', '');
803 return FALSE;
804 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException $e) {
805 $this->writelog(9, 1, 100, 'File "%s" was not saved! Write-permission problem?', array($fileObject->getIdentifier()));
806 return FALSE;
807 } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
808 $this->writelog(9, 1, 100, 'File "%s" was not saved! File extension rejected!', array($fileObject->getIdentifier()));
809 return FALSE;
810 }
811 }
812
813 /**
814 * Upload of files (action=1)
815 * when having multiple uploads (HTML5-style), the array $_FILES looks like this:
816 * Array(
817 * [upload_1] => Array(
818 * [name] => Array(
819 * [0] => GData - Content-Elements and Media-Gallery.pdf
820 * [1] => CMS Expo 2011.txt
821 * )
822 * [type] => Array(
823 * [0] => application/pdf
824 * [1] => text/plain
825 * )
826 * [tmp_name] => Array(
827 * [0] => /Applications/MAMP/tmp/php/phpNrOB43
828 * [1] => /Applications/MAMP/tmp/php/phpD2HQAK
829 * )
830 * [size] => Array(
831 * [0] => 373079
832 * [1] => 1291
833 * )
834 * )
835 * )
836 * in HTML you'd need sth like this: <input type="file" name="upload_1[]" multiple="true" />
837 *
838 * @param array $cmds $cmds['data'] is the ID-number (points to the global var that holds the filename-ref ($_FILES['upload_' . $id]['name']) . $cmds['target'] is the target directory, $cmds['charset'] is the the character set of the file name (utf-8 is needed for JS-interaction)
839 * @return File[] | FALSE Returns an array of new file objects upon success. False otherwise
840 */
841 public function func_upload($cmds) {
842 if (!$this->isInit) {
843 return FALSE;
844 }
845 $uploadPosition = $cmds['data'];
846 $uploadedFileData = $_FILES['upload_' . $uploadPosition];
847 if (empty($uploadedFileData['name']) || is_array($uploadedFileData['name']) && empty($uploadedFileData['name'][0])) {
848 $this->writelog(1, 2, 108, 'No file was uploaded!', '');
849 return FALSE;
850 }
851 // Example indentifier for $cmds['target'] => "2:targetpath/targetfolder/"
852 $targetFolderObject = $this->getFileObject($cmds['target']);
853 // Uploading with non HTML-5-style, thus, make an array out of it, so we can loop over it
854 if (!is_array($uploadedFileData['name'])) {
855 $uploadedFileData = array(
856 'name' => array($uploadedFileData['name']),
857 'type' => array($uploadedFileData['type']),
858 'tmp_name' => array($uploadedFileData['tmp_name']),
859 'size' => array($uploadedFileData['size'])
860 );
861 }
862 $resultObjects = array();
863 $numberOfUploadedFilesForPosition = count($uploadedFileData['name']);
864 // Loop through all uploaded files
865 for ($i = 0; $i < $numberOfUploadedFilesForPosition; $i++) {
866 $fileInfo = array(
867 'name' => $uploadedFileData['name'][$i],
868 'type' => $uploadedFileData['type'][$i],
869 'tmp_name' => $uploadedFileData['tmp_name'][$i],
870 'size' => $uploadedFileData['size'][$i]
871 );
872 try {
873 // @todo can be improved towards conflict mode naming
874 if ($this->dontCheckForUnique) {
875 $conflictMode = 'replace';
876 } else {
877 $conflictMode = 'cancel';
878 }
879 /** @var $fileObject File */
880 $fileObject = $targetFolderObject->addUploadedFile($fileInfo, $conflictMode);
881 $fileObject = ResourceFactory::getInstance()->getFileObjectByStorageAndIdentifier($targetFolderObject->getStorage()->getUid(), $fileObject->getIdentifier());
882 if ($conflictMode === 'replace') {
883 $this->getIndexer($fileObject->getStorage())->updateIndexEntry($fileObject);
884 }
885 $resultObjects[] = $fileObject;
886 $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
887 $this->writelog(1, 0, 1, 'Uploading file "%s" to "%s"', array($fileInfo['name'], $targetFolderObject->getIdentifier()));
888 } catch (\TYPO3\CMS\Core\Resource\Exception\UploadException $e) {
889 $this->writelog(1, 2, 106, 'The upload has failed, no uploaded file found!', '');
890 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
891 $this->writelog(1, 1, 105, 'You are not allowed to upload files!', '');
892 } catch (\TYPO3\CMS\Core\Resource\Exception\UploadSizeException $e) {
893 $this->writelog(1, 1, 104, 'The uploaded file "%s" exceeds the size-limit', array($fileInfo['name']));
894 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException $e) {
895 $this->writelog(1, 1, 103, 'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier()));
896 } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
897 $this->writelog(1, 1, 102, 'Extension of file name "%s" is not allowed in "%s"!', array($fileInfo['name'], $targetFolderObject->getIdentifier()));
898 } catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException $e) {
899 $this->writelog(1, 1, 101, 'No unique filename available in "%s"!', array($targetFolderObject->getIdentifier()));
900 } catch (\RuntimeException $e) {
901 $this->writelog(1, 1, 100, 'Uploaded file could not be moved! Write-permission problem in "%s"?', array($targetFolderObject->getIdentifier()));
902 }
903 }
904
905 return $resultObjects;
906 }
907
908 /**
909 * Unzipping file (action=7)
910 * This is permitted only if the user has fullAccess or if the file resides
911 *
912 * @param array $cmds $cmds['data'] is the zip-file. $cmds['target'] is the target directory. If not set we'll default to the same directory as the file is in.
913 * @return bool Returns TRUE on success
914 */
915 public function func_unzip($cmds) {
916 if (!$this->isInit || $this->dont_use_exec_commands) {
917 return FALSE;
918 }
919 $theFile = $cmds['data'];
920 if (!@is_file($theFile)) {
921 $this->writelog(7, 2, 105, 'The file "%s" did not exist!', array($theFile));
922 return FALSE;
923 }
924 $fI = GeneralUtility::split_fileref($theFile);
925 if (!isset($cmds['target'])) {
926 $cmds['target'] = $fI['path'];
927 }
928 // Clean up destination directory
929 // !!! Method has been put in the local driver, can be saftely removed
930 $theDest = $this->is_directory($cmds['target']);
931 if (!$theDest) {
932 $this->writelog(7, 2, 104, 'Destination "%s" was not a directory', array($cmds['target']));
933 return FALSE;
934 }
935 if (!$this->actionPerms['unzipFile']) {
936 $this->writelog(7, 1, 103, 'You are not allowed to unzip files', '');
937 return FALSE;
938 }
939 if ($fI['fileext'] != 'zip') {
940 $this->writelog(7, 1, 102, 'File extension is not "zip"', '');
941 return FALSE;
942 }
943 if (!$this->checkIfFullAccess($theDest)) {
944 $this->writelog(7, 1, 101, 'You don\'t have full access to the destination directory "%s"!', array($theDest));
945 return FALSE;
946 }
947 // !!! Method has been put in the sotrage driver, can be saftely removed
948 if ($this->checkPathAgainstMounts($theFile) && $this->checkPathAgainstMounts($theDest . '/')) {
949 // No way to do this under windows.
950 $cmd = $this->unzipPath . 'unzip -qq ' . escapeshellarg($theFile) . ' -d ' . escapeshellarg($theDest);
951 CommandUtility::exec($cmd);
952 $this->writelog(7, 0, 1, 'Unzipping file "%s" in "%s"', array($theFile, $theDest));
953 return TRUE;
954 } else {
955 $this->writelog(7, 1, 100, 'File "%s" or destination "%s" was not within your mountpoints!', array($theFile, $theDest));
956 return FALSE;
957 }
958 }
959
960 /**
961 * Add flash message to message queue
962 *
963 * @param FlashMessage $flashMessage
964 * @return void
965 */
966 protected function addFlashMessage(FlashMessage $flashMessage) {
967 /** @var $flashMessageService FlashMessageService */
968 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
969
970 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
971 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
972 $defaultFlashMessageQueue->enqueue($flashMessage);
973 }
974
975 /**
976 * Gets Indexer
977 *
978 * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
979 * @return \TYPO3\CMS\Core\Resource\Index\Indexer
980 */
981 protected function getIndexer(ResourceStorage $storage) {
982 return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Index\Indexer::class, $storage);
983 }
984
985 /**
986 * Get database connection
987 *
988 * @return \TYPO3\CMS\Core\Database\DatabaseConnection
989 */
990 protected function getDatabaseConnection() {
991 return $GLOBALS['TYPO3_DB'];
992 }
993
994 /**
995 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
996 */
997 protected function getBackendUser() {
998 return $GLOBALS['BE_USER'];
999 }
1000
1001 }