4
Proposed lame implementation (in ugly pseudocode
):
New core function:
xoopsDb->vcsinsert**Module developers can call it right before each
$xoopsDB->query($sql);, uses the same
$sql variable that will be used for updating or deleting data.
function vcsinsert() {
if (ereg("DELETE FROM", $sql)) { //Is it a DELETE query?
$sqlvcs_sel = str_replace("DELETE", "SELECT *", $sql);
$result = $xoopsDB->query($sqlvcs_sel);
$vcsdata= base64_encode(serialize($result));
$vcsinsert= "INSERT INTO ´xoops_vcs´ (`vcs_id`,`vcs_content`,`vcsdate`) VALUES (´".$vcsid."´, ´".$vcsdata."´, ´somedate´)";
$xoopsDB->query($vcsinsert);
}
elseif (eregi("UPDATE [:print:]* SET", $sql)) { //Is it an UPDATE query?
$sv_sel = str_replace("SET [:print:]* WHERE", "", $sql);
$sqlvcs_sel = str_replace("UPDATE", "SELECT * FROM", $sql);
$result = $xoopsDB->query($sqlvcs_sel);
$vcsdata= base64_encode(serialize($result));
$vcsinsert= "INSERT INTO ´xoops_vcs´ (`vcs_id`,`vcs_content`,`vcsdate`) VALUES (´".$vcsid."´, ´".$vcsdata."´, ´somedate´)";
$xoopsDB->query($vcsinsert);
}
else {echo "The VCS has found an error and borked like totally";}
There. The old data is lamely saved, regardless of table structure, for mod developers to retrieve when needed.
AFAICS i's well implemented in the
Version Control Class and something similar could be added to the core without affecting anything that doesn't ask for a backup/old version/undo query. Opinions?