35 parent::__construct();
37 $this->
cli_help[
'name'] =
'missing_files -- Find all file references from records pointing to a missing (non-existing) file.';
38 $this->
cli_help[
'description'] = trim(
' 40 - a perfect integrity of the reference index table (always update the reference index table before using this tool!) 41 - relevant soft reference parsers applied everywhere file references are used inline 43 Files may be missing for these reasons (except software bugs): 44 - someone manually deleted the file inside fileadmin/ or another user maintained folder. If the reference was a soft reference (opposite to a TCEmain managed file relation from "group" type fields), technically it is not an error although it might be a mistake that someone did so. 45 - someone manually deleted the file inside the uploads/ folder (typically containing managed files) which is an error since no user interaction should take place there. 47 Automatic Repair of Errors: 48 - Managed files (TCA/FlexForm attachments): Will silently remove the reference from the record since the file is missing. For this reason you might prefer a manual approach instead. 49 - Soft References: Requires manual fix if you consider it an error. 51 Manual repair suggestions: 52 - Managed files: You might be able to locate the file and re-insert it in the correct location. However, no automatic fix can do that for you. 53 - Soft References: You should investigate each case and edit the content accordingly. A soft reference to a file could be in an HTML image tag (for example <img src="missing_file.jpg" />) and you would have to either remove the whole tag, change the filename or re-create the missing file. 55 $this->
cli_help[
'examples'] =
'/.../cli_dispatch.phpsh lowlevel_cleaner missing_files -s -r 56 This will show you missing files in the TYPO3 system and only report back if errors were found.';
70 $listExplain =
' Shows the relative filename of missing file as header and under a list of record fields in which the references are found. ' .
$this->label_infoString;
72 'message' => $this->
cli_help[
'name'] . LF . LF . $this->
cli_help[
'description'],
74 'managedFilesMissing' => array(
'List of missing files managed by TCEmain', $listExplain, 3),
75 'softrefFilesMissing' => array(
'List of missing files registered as a soft reference', $listExplain, 2)
77 'managedFilesMissing' => array(),
78 'softrefFilesMissing' => array()
81 $recs = $TYPO3_DB->exec_SELECTgetRows(
'*',
'sys_refindex',
'ref_table=' . $TYPO3_DB->fullQuoteStr(
'_FILE',
'sys_refindex'),
'',
'sorting DESC');
83 if (is_array($recs)) {
84 foreach ($recs as $rec) {
86 $infoString = $this->
infoStr($rec);
88 if (!@is_file((PATH_site . $rec[
'ref_string']))) {
89 if ((
string) $rec[
'softref_key'] ==
'') {
90 $resultArrayIndex =
'managedFilesMissing';
92 $resultArrayIndex =
'softrefFilesMissing';
94 $resultArray[$resultArrayIndex][$rec[
'ref_string']][$rec[
'hash']] = $infoString;
95 ksort($resultArray[$resultArrayIndex][$rec[
'ref_string']]);
99 ksort($resultArray[
'managedFilesMissing']);
100 ksort($resultArray[
'softrefFilesMissing']);
113 foreach ($resultArray[
'managedFilesMissing'] as $key => $value) {
114 echo
'Processing file: ' . $key . LF;
116 foreach ($value as $hash => $recReference) {
117 echo
' Removing reference in record "' . $recReference .
'": ';
122 $error = $sysRefObj->setReferenceValue($hash, NULL);
124 echo
' TYPO3\\CMS\\Core\\Database\\ReferenceIndex::setReferenceValue(): ' . $error . LF;
125 echo
'missing_files: exit on error' . LF;
static makeInstance($className)
cli_noExecutionCheck($matchString)
main_autoFix($resultArray)