PHPackages                             nswdpc/silverstripe-pruner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. nswdpc/silverstripe-pruner

ActiveSilverstripe-vendormodule[Database &amp; ORM](/categories/database)

nswdpc/silverstripe-pruner
==========================

Prune records from configured DataObject classes

v1.0.0(1y ago)02.9k1[1 issues](https://github.com/nswdpc/silverstripe-pruner/issues)1BSD-3-ClausePHP

Since Oct 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nswdpc/silverstripe-pruner)[ Packagist](https://packagist.org/packages/nswdpc/silverstripe-pruner)[ RSS](/packages/nswdpc-silverstripe-pruner/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (8)Used By (1)

Pruner
======

[](#pruner)

Removes records from the database attached to a Silverstripe project, using a queued job with configurable options.

It can be applied to any `SilverStripe\ORM\DataObject` record and is useful for records in tables that can continue to grow, like form submissions.

Install
-------

[](#install)

```
composer require nswdpc/silverstripe-pruner
```

Userforms support
-----------------

[](#userforms-support)

See `nswdpc/silverstripe-pruner-userforms` module for silverstripe/userforms support.

Requirements
------------

[](#requirements)

See composer.json

Configuration
-------------

[](#configuration)

Configure a project .yml file like so:

```
---
Name: prunerconfiglocal
After:
  - '#nswdpc-pruner'
---
NSWDPC\Pruner\Pruner:
  # sample target_models
  target_models:
    # remove/backup submitted forms from the userforms module
    - 'SilverStripe\UserForms\Model\Submission\SubmittedForm'
    # a namespaced DataObject
    - 'Some\Namespaced\DataObject'
```

Interface
---------

[](#interface)

When adding a `SilverStripe\ORM\DataObject` to the list of `target_models`, these DataObjects must:

- implement the interface `NSWDPC\Utility\Pruner\Interfaces\PrunerInterface` OR
- have an extension that implements that Interface

The module will ignore models passed to it that do not implement this interface.

See the `PrunerInterface` for documentation.

Pruning records via the queued job
----------------------------------

[](#pruning-records-via-the-queued-job)

The `PruneJob` exists to remove the relevant records from the target models.

You can pass in the following constructor arguments:

- `$days_ago` - the minimum number of days in the past records should be truncated. Older records are removed first. Default = 30
- `$limit` - the maximum number of records to remove at one time. Default = 50 (in the case of SubmittedForm records this is a limit per parent class)
- `$targets` - a comma separated model of DataObject classnames (namespace). If left empty the configured names will be used, if any. This allow you to schedule removal of a certain class of records at a certain time.
- `$report_only` - 0|1 - pass in 1 to only report on what would be removed.

### Returning a list of records to remove

[](#returning-a-list-of-records-to-remove)

While the most common list to return would be records older than the `days_ago` age parameter, you are in control of how records are filtered as returned from `pruneList`.

You can add extra filters to the query or modify/ignore the age parameter entirely. For instance, you could remove records older than a certain date and not authored by members in a specific domain.

Operations pre/post prune
-------------------------

[](#operations-prepost-prune)

In addition to the usual onBeforeDelete/onAfterDelete Silverstripe methods, the module calls onBeforePrune and onAfterPrune before/after record deletion, respectively.

The order of operation for each record removal is:

1. onBeforePrune
2. delete action:
    1. onBeforeDelete
    2. delete
    3. onAfterDelete
3. onAfterPrune

You must implement these methods, even if you are not carrying out any actions pre/post record pruning.

Reporting task
--------------

[](#reporting-task)

A task exists to provide quick report showing what would be removed based on the arguments provided:

Report for the targeted models, older than 15 days, limit 50 records removed per model

```
./vendor/bin/sake dev/tasks/ReportOnlyPrunerTask age=15 limit=50 targets=SilverStripe\\UserForms\\Model\\Submission\\SubmittedForm
```

Multiple targets can be separated by a comma. If not targets are provided, the configured value of `NSWDPC\Pruner\Pruner.target_models` is used.

Maintainers
-----------

[](#maintainers)

- [dpcdigital@NSWDPC:~$](https://dpc.nsw.gov.au)

License
-------

[](#license)

[BSD-3-Clause](./LICENSE.md)

Security
--------

[](#security)

If you have found a security issue with this module, please email digital\[@\]dpc.nsw.gov.au in the first instance, detailing your findings.

Bugtracker
----------

[](#bugtracker)

We welcome bug reports, pull requests and feature requests on the Github Issue tracker for this project.

Please review the [code of conduct](./code-of-conduct.md) prior to opening a new issue.

Development and contribution
----------------------------

[](#development-and-contribution)

If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.

Please review the [code of conduct](./code-of-conduct.md) prior to completing a pull request.

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~131 days

Recently: every ~99 days

Total

6

Last Release

652d ago

Major Versions

v0.2.0-rc1 → v1.0.0-rc12023-06-26

v0.2.2 → v1.0.02024-07-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/1caefd99092b4a43254e48c40347224f671032ec1ffc3a457e06a7e9ab6e7c02?d=identicon)[nswdpc](/maintainers/nswdpc)

---

Top Contributors

[![JamesDPC](https://avatars.githubusercontent.com/u/69664712?v=4)](https://github.com/JamesDPC "JamesDPC (25 commits)")[![tardinha](https://avatars.githubusercontent.com/u/457209?v=4)](https://github.com/tardinha "tardinha (3 commits)")

---

Tags

deleteremovetruncatepruning

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/nswdpc-silverstripe-pruner/health.svg)

```
[![Health](https://phpackages.com/badges/nswdpc-silverstripe-pruner/health.svg)](https://phpackages.com/packages/nswdpc-silverstripe-pruner)
```

###  Alternatives

[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[coffeecode/datalayer

The data layer is a persistent abstraction component of your database that PDO

33843.6k4](/packages/coffeecode-datalayer)[vectorial1024/laravel-cache-evict

Efficiently remove expired Laravel file/database cache data

5813.2k](/packages/vectorial1024-laravel-cache-evict)[spatie/laravel-queued-db-cleanup

Safely delete large numbers of records

81355.6k1](/packages/spatie-laravel-queued-db-cleanup)[pgbi/cakephp3-soft-delete

SoftDelete plugin for CakePHP

87291.9k](/packages/pgbi-cakephp3-soft-delete)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41249.0k6](/packages/atlas-query)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
