TaviBug:829113: Pages deleted when $ExpireLen=0. Status: Fixed, as of version 0.25

It was detected that if setting $ExpireLen=0, as suggested in ExpirationPeriod or DocumentExpiration, all versions of a page beside the latest version was deleted after a day. This is unfortunate, and was fixed immediately. And this page added to the main site to provide information on how to fix this error in previous version, if one needs to.

The fix is to add some code in the file lib/pagestore.php in the function maintain() near the end of the file. The original code excerpt was:

  while(($result = $this->dbh->result($qid)))
    {
      $result[0] = addslashes($result[0]);
      $this->dbh->query("DELETE FROM $PgTbl WHERE title='$result[0]' AND " .
                        "(version < $result[1] OR body='') AND " .
                        "TO_DAYS(NOW()) - TO_DAYS(supercede) > $ExpireLen");
    }

and this should be changed to:

  if ($ExpireLen != 0) 
    {
      while(($result = $this->dbh->result($qid)))
      {
        $result[0] = addslashes($result[0]);
        $this->dbh->query("DELETE FROM $PgTbl WHERE title='$result[0]' AND " .
                          "(version < $result[1] OR body='') AND " .
                          "TO_DAYS(NOW()) - TO_DAYS(supercede) > $ExpireLen");
      }
    }

In other words add if ($ExpireLen? != 0) { before the while-loop, and a single } after the while loop in lines around 321-327 in the given file.