axllent/silverstripe-version-truncator 问题修复 & 功能扩展

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

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

axllent/silverstripe-version-truncator

最新稳定版本:4.0.0

Composer 安装命令:

composer require axllent/silverstripe-version-truncator

包简介

Automatically delete old versioned Silverstripe records from the database

README 文档

README

An extension for Silverstripe to automatically delete old versioned DataObject records from your database when a record is published, following predefined retention policies (see configuration).

When a record is being edited (such as a Page), no changes are made until it is published, so it could have 50 draft versions while you work on the copy. When you publish the page, the module prunes the (by default) all draft copies, leaving just the 10 latest published versions (configurable).

Features

  • Delete all but the last XX published versions of a DataObject on publish
  • Delete all but the last YY draft versions of a DataObject on publish
  • Optionally keep old SiteTree objects where the URLSegment has changed (to preserve redirects)

Tasks

The module adds four manual tasks to:

  1. Force a run over the entire database - this task is generally not needed unless you either just install the module and wish to tidy up, or change your DataObject configurations.
  2. Silverstripe does not currently delete any File records once the file had been physically deleted (probably due to the immediate post-delete functionality relating to internal file linking). I cannot see any purpose of keeping these records after this, so this task will remove all records pertaining to deleted files/folders.
  3. Force a "reset", keeping only the latest published version of each currently published DataObject (regardless of policy). Unpublished / modified DataObjects are not touched.
  4. Delete all archived DataObjects.

The tasks can be run in your browser via /dev/tasks/TruncateVersionsTask, or see sake tasks:TruncateVersionsTask --help for CLI options.

Requirements

  • Silverstripe ^6.0

Please see the 3 branch for Silverstripe 4 & 5 support.

Installation

composer require axllent/silverstripe-version-truncator

Configuration

Configuration is optional (see Default config), however you can create a YML file (eg: app/_config/version-truncator.yml):

MyCustomObject: keep_versions: 5 keep_drafts: 5

To skip pruning altogether for a particular DataObject, set keep_versions: 0 for that object class.

To overwrite the global defaults, see _config/extension.yml, eg:

SilverStripe\CMS\Model\SiteTree: keep_versions: 20 keep_drafts: 10

Default config

SiteTree (and extending classes eg: Page etc)

On publish, the last 10 published versions are kept, and all draft copied are removed. The only exception is if the URLSegment and/or ParentID is has changed, in which case the module will keep a single record for each differing URLSegment to allow auto-redirection.

All other DataObjects

For all other versioned DataObjects, only the latest published version is kept, and all drafts deleted. This can be adjusted per DataObject, or globally (see above).

统计信息

  • 总下载量: 68.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 36
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 1

GitHub 信息

  • Stars: 36
  • Watchers: 3
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固