Item changelogs and rollback

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have been wanting to add a changelog capability to our in house CMS
system.  The approach I was thinking of was adding a changelog table
to the database. It records the ID of the editor, the timestamp of
when the edit occurred and a list of changes made to the item

I would like to add this capability for 2 reasons:

a) To see what changes have been made to an article since its last
b) To be able to "roll back" changes to an earlier revision if

The easy way would be to simply store the entire text of the article
each time in the changelog, but that is of course very wasteful.  What
I'd really like to do is store the difference between the current and
the previous version.

Is there a way of achieving this in PHP? I found a few functions in
the manual that claim to analyse strings and work out the differences
but these functions seem to return integers, and what I'd ideally need
is something akin to the output of utilities like diff.

Re: Item changelogs and rollback

Gordon wrote:
Quoted text here. Click to load it

You can do it, but it will be complicated.  If you can exec() diff and
patch, that will help (but you'll have to save the article to a file
temporarily, anyway).  Otherwise you'll need to write your own code to
get the differences and make the changes.

I think it would be easier to just store the entire article.  They
aren't that big, are they?

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Item changelogs and rollback

Quoted text here. Click to load it

Why not use diff with temporary files (see also man patch). But it
might just be simpler to maintain the content in numbered files via


Site Timeline