Maintenance 

There are various maintenance tasks which can be performed to maintain a healthy TYPO3 installation with the file abstraction layer.

Scheduler tasks 

The typo3/cms-scheduler system extension provides two main tasks related to the file abstraction layer.

File abstraction layer: Update storage index

This task goes through a storage and makes sure that each file is properly indexed. If files are only manipulated via the TYPO3 backend, they are always indexed. However, if files are added by other means (for example, FTP), or if some storages are based on drivers accessing remote systems, it is essential to run this task regularly so that the TYPO3 installation knows about all the existing files and can make them available to users.

This task is defined per storage.

File abstraction layer: Extract metadata in storage

This task goes through all files in a storage and updates their metadata. Again, this is especially important when files can be manipulated by other means or actually reside on external systems.

This task is defined per storage.

Processed files 

If you change some graphics-related settings, it may be necessary to force a regeneration of all processed files. This can be achieved by deleting all existing processed files in System > Maintenance > Remove Temporary Assets.

Removing all processed files in the Maintenance Tool

Here you can choose to delete all files in fileadmin/_processed_/. Processed images from extensions are in typo3temp/assets/images/.

This cleanup is also a good idea if you have been accumulating files for a long time. Many of them may be obsolete.

After flushing page cache, it is a good idea to warmup the page cache. Generating the pages for the first time may take longer than usual because the processed files need to be regenerated. There is currently no Core functionality to warmup the page cache for all pages, but there are a number of extensions which provide this functionality. Alternatively, one can use the sitemap and a tool such as wget for this.

Also, deleting processed files while editors are active is not ideal. Preferably, lock the TYPO3 backend before you remove the processed files.

Cleaning up processed files on the command line 

The console command vendor/bin/typo3 cleanup:localprocessedfiles from system extension typo3/cms-lowlevel removes processed files that are no longer needed from local storage (Local driver rather than cloud storage). It deletes:

  • files in the processing folders that are not referred to by any sys_file_processedfile records, and
  • sys_file_processedfile records where the processed file no longer exists.

Show which files and records the command would delete, without deleting them:

vendor/bin/typo3 cleanup:localprocessedfiles --dry-run -v
Copied!
typo3/sysext/core/bin/typo3 cleanup:localprocessedfiles --dry-run -v
Copied!

The command asks for confirmation before deletion. Option -f (--force) skips confirmation, as does running the command without interaction, for example when running it as a scheduler task for regular cleanup.

Option --all deletes processed files in all storage and all the associated records, including those still in use. TYPO3 then recreates the processed files, which is useful, for example, if a new file processor has been added. Flush the page cache afterwards, as described above.

Removing records of missing files 

A file that is deleted outside of TYPO3, for example with FTP, or that is missing after a database dump was restored without the matching files, keeps its records in sys_file and sys_file_metadata . When the storage is indexed, TYPO3 flags the file as missing. The System > Reports module lists these files under "Files flagged as missing".

The console command cleanup:missingfiles from system extension typo3/cms-lowlevel removes the records of missing files, the same way as when a file is deleted in TYPO3: the file and metadata records, their category relations, their processed files, and left-over deleted file references.

The command keeps the records of a missing file that is still referenced, also by a link such as t3://file?uid=…. With option -v, it lists these files, so that you can restore the file or remove the references.

vendor/bin/typo3 cleanup:missingfiles

vendor/bin/typo3 cleanup:missingfiles
Removes database records of indexed files that are flagged as missing and no longer referenced
Usage
vendor/bin/typo3 cleanup:missingfiles [--dry-run] [--update-refindex] [--update-storage UPDATE-STORAGE]
Copied!
Options
--dry-run
If this option is set, no records are removed, only the records that would be removed are shown
Value
None allowed
Default value
false
--update-refindex
Setting this option automatically updates the reference index and does not ask on command line. Alternatively, use -n to avoid the interactive mode
Value
None allowed
Default value
false
--update-storage
Update the storage index of the storage with the given uid first, so that files deleted outside of TYPO3 are flagged as missing. Can be given multiple times, "all" updates all storages
Value
Required (multiple)
Default value
[]

The reference index decides whether a file is still referenced, so update it first, see Update the reference index.

Without --update-refindex and --update-storage, the command asks whether it should update the reference index and the index of all storages. Without interaction (option -n), for example in a scheduler task, it does not update them.

Show which records would be removed, after updating the reference index and the index of storage 1:

vendor/bin/typo3 cleanup:missingfiles --dry-run -v --update-refindex --update-storage=1
Copied!
typo3/sysext/core/bin/typo3 cleanup:missingfiles --dry-run -v --update-refindex --update-storage=1
Copied!

Remove the records:

vendor/bin/typo3 cleanup:missingfiles --update-refindex --update-storage=all
Copied!
typo3/sysext/core/bin/typo3 cleanup:missingfiles --update-refindex --update-storage=all
Copied!