elementareteilchen/unduplicator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elementareteilchen/unduplicator

Composer 安装命令:

composer require elementareteilchen/unduplicator

包简介

Finds duplicates in sys_file and unduplicates them

README 文档

README

Finds and fixes duplicates of sys_file entries pointing to the same file. Merges all references to point to the remaining sys_file entry.

Tested successfully with TYPO3 v12.

Warning

Older versions for TYPO3 v8 may not consider identifiers with mixed case or sys_file entries on several storages (sys_file.storage) correctly, see issue #2

Portabilty (database)

In order to test for duplicates, a database command like this is used:

SELECT COUNT(*), MAX(identifier) AS identifier, storage FROM `sys_file` GROUP BY MD5(identifier), storage HAVING COUNT(*) > 1;

Therefore, it is necessary, that the underlying database engines support MAX and MD5. This command was tested with the following:

  • MariaDB
  • MySQL
  • Postgres

Usage

We strongly recommend to run the reference index update (before and after): If not run before or the references are out of date, some references may be overlooked and a sys_file entry deleted which has references. Additionally you should consider to run the scheduler task "File Abstraction Layer: Update storage index" (before and after): This makes sense to recalculate the hash or other information. Also, the scheduler may create further duplicates. (If we do not run it now and the files are indexed later, we have new duplicates which are not taken care of). You can run the scheduler task in the scheduler backend module or via CLI, see vendor/bin/typo3 help scheduler:run for details.

Create the beforementioned scheduler task and use the UID in the next command:

php vendor/bin/typo3 scheduler:run --task=<UID>

Then use the following commands:

# dry-run:
php vendor/bin/typo3 unduplicate:sysfile --update-refindex --dry-run
# for real
php vendor/bin/typo3 unduplicate:sysfile -n

Options

Option Alias Description
--dry-run -d Only shows the duplicates, but does not update the database.
--identifier -i Only consider duplicates with the given identifier.
--storage -s Only consider duplicates in the given storage.
--force -f Enforce keeping or overwriting of metadata of the master record in case of conflict. Possible values: keep, keep-nonempty, overwrite.
--keep-oldest -o Use the oldest record as master instead of the newest.
--meta-fields -m Check for conflicting metadata fields, see below.
--update-refindex -u Update the reference index before the operation.
--no-interaction -n Do not ask for the update of the reference index.

Run another reference index update when you are done:

php vendor/bin/typo3 referenceindex:update

Examples

# run for a specific storage and identifier
php vendor/bin/typo3 unduplicate:sysfile --storage 1 --identifier "/user_upload/duplicate.jpg"

# `--keep-oldest` can be used in conjunction with `--force keep` to keep the oldest entries as they are and delete all others
php vendor/bin/typo3 unduplicate:sysfile -n --force keep --keep-oldest

Note For non-composer-mode the path to the CLI script is typo3/sysext/core/bin/typo3

How the duplicate check is done

  • check if sys_file.storage and sys_file.identifier is the same, but sys_file.uid is different
  • we must make sure comparing identifier is done case-sensitively, this may not be the case for DB queries. In order to keep DB queries portable across different DB servers, we do an additional check in PHP.

Check for conflicting metadata

You can specify meta data fields to check for conflicts.

  • If a conflict is found, the script will not delete the old record but show a warning.
  • If the data is the same or the old has none, the old is deleted.
  • If the data in the new is empty, the data from the old will be copied, if present.
php vendor/bin/typo3 unduplicate:sysfile --meta-fields "description, caption"

If the extension filemetadata is installed, the default check is on description, copyright and caption. Otherwise only description is checked.

Run the functional Tests

composer install
./Build/Scripts/runTests.sh -s functional -d mariadb -p 8.3

elementareteilchen/unduplicator 适用场景与选型建议

elementareteilchen/unduplicator 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 3.01k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2023 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 elementareteilchen/unduplicator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 elementareteilchen/unduplicator 我们能提供哪些服务?
定制开发 / 二次开发

基于 elementareteilchen/unduplicator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.01k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 5
  • Forks: 4
  • 开发语言: Shell

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-05-08