elementareteilchen / unduplicator
在sys_file中查找重复项并去重
v2.1.0
2024-07-29 12:07 UTC
Requires
- php: ^8.1 || ^8.2 || ^8.3
- ext-pdo: *
- typo3/cms-core: ^12.4
Requires (Dev)
- phpunit/phpunit: ^11
- typo3/testing-framework: 8.2.0
README
查找并修复指向相同文件的sys_file条目的重复项。合并所有引用以指向剩余的sys_file条目。
已成功测试与TYPO3 v12兼容。
警告
对于TYPO3 v8的旧版本,可能无法正确处理混合大小写的标识符或多个存储(sys_file.storage)上的sys_file条目,请参阅问题#2
用法
我们强烈建议运行引用索引更新(在前后):如果没有在之前运行,或者引用已过时,可能会忽略一些引用并删除具有引用的sys_file条目。此外,您还应该考虑运行调度任务“文件抽象层:更新存储索引”(在前后):这有助于重新计算哈希或其他信息。此外,调度程序可能会创建更多的重复项。(如果我们现在不运行它,然后在文件稍后索引,我们将有新的重复项,这些重复项没有得到处理)。您可以在调度程序后端模块或通过CLI运行调度程序任务,有关详细信息,请参阅vendor/bin/typo3 help scheduler:run
。
使用以下命令
php vendor/bin/typo3 referenceindex:update
# create the beforementioned scheduler task and use the UID in the next command
#php vendor/bin/typo3 scheduler:run --task=<UID>
# dry-run (just show found duplicates, does not update database):
php vendor/bin/typo3 unduplicate:sysfile --dry-run
# for real
php vendor/bin/typo3 unduplicate:sysfile
php vendor/bin/typo3 referenceindex:update
注意 对于非composer模式,CLI脚本的路径是
typo3/sysext/core/bin/typo3
如果您只想为特定的存储或标识符(通过dry-run找到)运行去重器
php vendor/bin/typo3 unduplicate:sysfile --storage <storage> --identifier <"identifier">
# For example:
php vendor/bin/typo3 unduplicate:sysfile --storage 1 --identifier "/user_upload/duplicate.jpg"
如何进行重复检查
- 检查sys_file.storage和sys_file.identifier是否相同,但sys_file.uid不同
- 我们必须确保比较标识符时是区分大小写的,这可能不适用于数据库查询。为了在不同数据库服务器之间保持数据库查询的可移植性,我们在PHP中进行了额外的检查。
运行功能测试
./Build/Scripts/runTests.sh -s functional -d mariadb -p 8.3