Skip to content
Snippets Groups Projects
Commit d5c4bf5a authored by Benni Mack's avatar Benni Mack Committed by Anja Leichsenring
Browse files

[BUGFIX] Allow lowlevel cleaner missing files check for filenames with anchor

The lowlevel cleaner "missing files" detects files like "filepath/file.pdf#page-15"
as missing as the "#" is considered part of the filename.

A new check now properly detects this.

Resolves: #84999
Releases: master, 9.5
Change-Id: Ic394f7d34e993807e932ebc3ac438f31f50dcb32
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63819


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarSusanne Moog <look@susi.dev>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarSusanne Moog <look@susi.dev>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent 0597c093
Branches
Tags
No related merge requests found
......@@ -174,7 +174,7 @@ If you want to get more detailed information, use the --verbose option.')
// Traverse the references and check if the files exists
while ($record = $result->fetch()) {
$fileName = $record['ref_string'];
$fileName = $this->getFileNameWithoutAnchor($record['ref_string']);
if (empty($record['softref_key']) && !@is_file(Environment::getPublicPath() . '/' . $fileName)) {
$missingReferences[$fileName][$record['hash']] = $this->formatReferenceIndexEntryToString($record);
}
......@@ -207,7 +207,7 @@ If you want to get more detailed information, use the --verbose option.')
// Traverse the references and check if the files exists
while ($record = $result->fetch()) {
$fileName = $record['ref_string'];
$fileName = $this->getFileNameWithoutAnchor($record['ref_string']);
if (!@is_file(Environment::getPublicPath() . '/' . $fileName)) {
$missingReferences[] = $fileName . ' - ' . $record['hash'] . ' - ' . $this->formatReferenceIndexEntryToString($record);
}
......@@ -215,6 +215,20 @@ If you want to get more detailed information, use the --verbose option.')
return $missingReferences;
}
/**
* Remove a possible anchor like 'my-path/file.pdf#page15'
*
* @param string $fileName a filename as found in sys_refindex.ref_string
* @return string the filename but leaving everything behind #page15 behind
*/
protected function getFileNameWithoutAnchor(string $fileName): string
{
if (strpos($fileName, '#') !== false) {
[$fileName] = explode('#', $fileName);
}
return $fileName;
}
/**
* Removes all references in the sys_file_reference where files were not found
*
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment