Re: Item changelogs and rollback
- From: r0g <aioe.org@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 29 Sep 2008 13:07:46 -0400
Gordon wrote:
On Sep 29, 12:53 pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@xxxxxxxxx> wrote:
On 29 Sep, 12:39, Gordon <gordon.mc...@xxxxxxxxxxxx> wrote:
I have been wanting to add a changelog capability to our in house CMSWhy not use diff with temporary files (see also man patch). But it
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
edited.
I would like to add this capability for 2 reasons:
a) To see what changes have been made to an article since its last
edit
b) To be able to "roll back" changes to an earlier revision if
necessary
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.
might just be simpler to maintain the content in numbered files via
CVS?
C.
My first thought was to do that, but to be honest I'd rather not be
dependant on a host having particular extermal programs available, as
the CMS needs to run in several different environments and with
different configurations. Some will have the exec() function disabled,
some won't have Diff installed (for example PHP on a Windows server).
I did take a brief look at xdiff but ruled it out for the same
reason.
The MediaWiki software seems to support what I want to be able to do
without resorting to extensions or external programs, but
unfortunately the MediaWiki source code is rather tricky to follow and
I've not managed to work out how it works yet.
I know it feels inefficient but you'd have to have an awful lot of
articles and an awful lot of revisions to make this a practical problem,
plus you'd be making your code slower and more complex; premature
optimisation yada yada yada...
If you expect your system to be used at the kind of scales where this
might be a serious issue how about datestamping and retiring your old
revisions from the database after a set period? You could have it zip
and mail you these as they are retired just dredge them back from your
backups if it turned out you needed them.
For something like this you may also want to consider just using flat
files, space is cheap and old revisions aren't likely to be needed that
often, why make your DB backups take longer?
If you are undissuadable then here's an implementation of diff in PHP
that may help... http://www.holomind.de/phpnet/diff.src.php
:-)
Roger Heathcote.
.
- Follow-Ups:
- Re: Item changelogs and rollback
- From: Gordon
- Re: Item changelogs and rollback
- References:
- Item changelogs and rollback
- From: Gordon
- Re: Item changelogs and rollback
- From: C. (http://symcbean.blogspot.com/)
- Re: Item changelogs and rollback
- From: Gordon
- Item changelogs and rollback
- Prev by Date: Re: include_once() and require_once() in function
- Next by Date: Re: include_once() and require_once() in function
- Previous by thread: Re: Item changelogs and rollback
- Next by thread: Re: Item changelogs and rollback
- Index(es):
Relevant Pages
|