Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1241 Need to put transaction around update_page

open
teedog
7
2014-06-21
2004-02-03
Terris Linenbach
No

If insert into tiki_history succeeds in
tikilib.php::update_page but the insert into tiki_pages
fails (e.g., corrupt index), it leaves a dangling row
in tiki_history which will cause problems the next time
the same page is updated even if the tiki_pages problem
is fixed. Of course the row can be manually deleted.

This is a fairly widespread problem in Tiki Wiki's code
base which is alarming due to the number of users it has.

Here is my crude fix that automatically deletes the
errant row in tiki_history:

if \($pageName \!= 'SandBox'\) \{
    $result =

$this->query($query,array($pageName,(int)
$version,(int)
$lastModif,$user,$ip,$comment,$data,$description),
-1, -1, false);
if (!$result)
{
$query2 = "delete from `tiki_history` where
`pageName`=? and `version`=?";
$result =
$this->query($query2,array($pageName,(int) $version));
$result =
$this->query($query,array($pageName,(int)
$version,(int)
$lastModif,$user,$ip,$comment,$data,$description),
-1, -1, false);
}
}

Discussion

  • teedog
    teedog
    2004-06-15

    • assigned_to: nobody --> teedog
    • status: open --> closed-accepted
     
  • teedog
    teedog
    2004-06-15

    Logged In: YES
    user_id=807810

    This looks like a good fix. I already encountered and fixed
    a similar bug with wiki tag restoration. This one will
    hopefully make other such bugs go away by themselves. Code
    committed in CVS HEAD. Thx terris.

     
  • teedog
    teedog
    2004-06-15

    Logged In: YES
    user_id=807810

    My bad. This solution doesn't work since tiki dies after
    the first query error. It never gets a chance to delete and
    reinsert.

     
  • teedog
    teedog
    2004-06-15

    • status: closed-accepted --> open