Jump to content

Recommended Posts

Posted (edited)

Hi everyone,

I'd like to share FwChangelog, a module that keeps a changelog for every page: what changed in each field (before and after), who changed it and when. It came out of a simple need on a multi-site install: someone changes content, and later we need to know who did it and what it was before.

The history lives in the page editor. The Settings tab gets a "Changelog" block with the number of logged edits and a "View History" link, which opens the history in a modal.

image.thumb.png.3e157e7ca4398767e9d554860e2556e2.pngimage.thumb.png.61699cb0b637bce2c4fe991cc6131165.png

 

What it logs?

  1. Field values, before and after, with the user and the date
  2. Multi-language fields, one entry per language that changed
  3. Page name, status (published, hidden, locked), parent and template
  4. Page created, moved to the trash and restored
  5. Files and images: added, removed, replaced, and description changes (file contents are never stored, only the file name)
  6. Page reference fields, as the titles and ids of the selected pages
  7. Repeater, RepeaterMatrix and FieldsetPage: changes inside items are logged on the page that owns them, including items added, removed and switched on or off
  8. Combo fields, one entry per changed subfield
  9. Toggle and checkbox values, shown with their labels instead of 0 and 1
  10. Password fields are logged as changed, without their values 

 

A few details

  1. Consecutive changes to the same field by the same user are merged into one entry (10 minutes by default), so quick re-saves and autosaves don't flood the history.
  2. Old entries are deleted automatically after a retention period (12 months by default). This needs the core LazyCron module.
  3. Paragraph-sized text is shown as one block with the changed words highlighted, shorter values are shown as the old value over the new one.
  4. Only changes made by a logged-in user are logged, so command-line imports running as guest are ignored. From code you can also wrap bulk changes in FwChangelog::pause() and FwChangelog::resume().
  5. Superusers always see the history, other users need the fw-changelog-view permission.
  6. All interface texts are translatable.

 

Performance

Nothing runs on the front end. On save, the module loads a fresh copy of the page and compares only the fields ProcessWire marked as changed, then writes the rows in its own table. The history is only queried when you open the modal.

 

image.thumb.png.5a2f9280e7bb6ddb1ffd17391585878e.png

 

Requirements

  1. ProcessWire 3.0.200 or newer
  2. LazyCron (core) for the automatic cleanup (everything else works without it)

 

Download

GitHub: https://github.com/joaochoupinaa/FwChangelog

 

Good to know

- Uninstalling the module drops its table, and the history with it.

- Reordering repeater items, files or images is not logged.

- RepeaterMatrix and Combo support was built and used on one production install with ProFields, reports from other setups are very welcome.

 

This is the first public release, so feedback, bug reports and ideas are welcome here or as GitHub issues.

 

Edited by joaomota
  • Like 5

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...