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
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. 5 1173
Gordon wrote:
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
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.
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. js*******@attglobal.net
==================
On 29 Sep, 12:39, Gordon <gordon.mc...@ntlworld.comwrote:
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
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.
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
CVS?
C.
On Sep 29, 12:53*pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 29 Sep, 12:39, Gordon <gordon.mc...@ntlworld.comwrote:
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
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.
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
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.
Gordon wrote:
On Sep 29, 12:53 pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
>On 29 Sep, 12:39, Gordon <gordon.mc...@ntlworld.comwrote:
>>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 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.
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 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.
On Sep 29, 6:07*pm, r0g <aioe....@technicalbloke.comwrote:
Gordon wrote:
On Sep 29, 12:53 pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 29 Sep, 12:39, Gordon <gordon.mc...@ntlworld.comwrote:
>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 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.
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
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.
Thanks for the script, I'll take a look into it when I can. I know
just saving the whole article every time would be easier, but I like a
challenge. :) Besides, to do the feature where you can see how one
revision differs from another would require some kind of way of
discovering the differences between two strings anyway. And from an
aesthetic point of view the idea of storing another entire copy just
for one or two corrected spelling mistakes just bothers me. It's not
a massively high priority feature, but as more and more users (most of
whom could find a way of screwing up a recipie for boiled eggs :P )
get added to the system a day is eventually going to come where
somebody does something they shouldn't. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: anders_tung |
last post by:
Hi,
I have a procedure which will call 3 functions.
First function will update a record.
Second function will delete a record.
Third function will insert a record.
Each function will return...
|
by: level8 |
last post by:
Hi, Everybody,
I'm a Hungarian SQL user and I need a little help for SQL Server 7 !
I protect my table against bad data with a trigger. I use ROLLBACK and
RAISERROR statement in this trigger....
|
by: cheesey_toastie |
last post by:
I have a long query which I have set off and would like to stop, and
rename one of the tables used.
My query is due to my lack of understanding of the underlying
structure of MSSQL-Server...
...
|
by: Ian Boyd |
last post by:
We're encountering a situation where we're encountering a deadlock, and
someone's been made the deadlock victim. But after that, DB2 refuses to run
any SQL, and instead we get the error message:
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |