Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to Delete Discussion and Comment revisions (Vanilla 2.1)?*

edited April 2012 in Vanilla 2.0 - 2.8

Vanilla uses MySQL, and probably stores revisions of Discussions and Comments (caused by edits) in the database like Wordpress. These can add up to the weight of the DB in the long-run.

Can someone tell me how to delete revisions in Vanilla forum's database? Thanks!

Best Answer

  • UnderDogUnderDog MVP
    Answer ✓

    Vanilla does not store revisions of discussions in the DataBase.

    You cannot go to an earlier version of a discussion (comment). If you edit a comment, that's the version that's stored in the database. The older version is not there anymore.

    There was an error rendering this rich post.

Answers

  • UnderDogUnderDog MVP
    Answer ✓

    Vanilla does not store revisions of discussions in the DataBase.

    You cannot go to an earlier version of a discussion (comment). If you edit a comment, that's the version that's stored in the database. The older version is not there anymore.

    There was an error rendering this rich post.

  • edited March 2012

    @UnderDog : That's kinda good news to me.

    I have one more question. Is there a way to disable the 'Change Log' feature (in Dashboard > Moderation > Change Log)?

    It don't want to manually delete all those by myself. If do share if you know how. Thanks.

    QUICK EDIT: Hmm... looks like there isn't a way to disable that. :(

  • peregrineperegrine MVP
    edited March 2012

    @badlearner

    Since the newer vanilla does indeed store revisions and deletions of comments and you you can restore them, which inevitably leads to a large log database if you don't delete the entries, it would be nice if there were a cleaner mod to turn it on and off.

    However, If you really want to disable additional log entries from being recorded - a modification to the core will work (but it is frowned upon to modify the core)

    look in applications/dashboard/models/class.logmodel.php (around line 257 in v2.18.04)

          Gdn::SQL()->Put(
                       'Log',
                       array('OtherUserIDs' => implode(',', $OtherUserIDs), 'CountGroup' => $Count, 'DateUpdated' => Gdn_Format::ToDateTime()),
                       array('LogID' => $LogID));
                 } else {
                    $LogID = Gdn::SQL()->Insert('Log', $LogRow);
                 }
              } else {
                 // Insert the log entry.
                $LogID = Gdn::SQL()->Insert('Log', $LogRow);
              }
              return $LogID;
    

    change the line(s) to

       // Insert the log entry.
                //    $LogID = Gdn::SQL()->Insert('Log', $LogRow);
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • If you really wanted something configurable you could do this to the core. It would be nice if this or something better were added to standard Vanilla.

    add this line to config.php
    // toggle TRUE and FALSE to log or not log.
    $Configuration['Garden']['EditDeleteLog'] = TRUE;

    and add this to applications/dashboard/models/class.logmodel.php (around line 257 in v2.18.04).

                Gdn::SQL()->Put(
                   'Log',
                   array('OtherUserIDs' => implode(',', $OtherUserIDs), 'CountGroup' => $Count, 'DateUpdated' => Gdn_Format::ToDateTime()),
                   array('LogID' => $LogID));
             } else {
                if (C('Garden.EditDeleteLog')) {
                  $LogID = Gdn::SQL()->Insert('Log', $LogRow);
                  }
             }
          } else {
             // Insert the log entry.
              if (C('Garden.EditDeleteLog')) {
             $LogID = Gdn::SQL()->Insert('Log', $LogRow);
               }
          }
          return $LogID;
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • edited April 2012

    @peregrine said: Since the newer vanilla does indeed store revisions and deletions of comments and you you can restore them ...

    But it's only the administrator's actions that are logged from what I see (moderators too?). Is that correct?

    EDITED: I just checked, unfortunately, my '/applications/dashboard/models/class.logmodel.php' file is different from yours as I am using Vanilla 2.1a (from GitHub). This is what the relevant piece of code in my file looks like:

        Gdn::SQL()->Put(
          'Log',
          $Set,
          array('LogID' => $LogID));
        } else {
        $L = self::_Instance();
        $L->EventArguments['Log'] =& $LogRow;
        $L->FireEvent('BeforeInsert');
    
        if (self::$_TransactionID > 0)
          $LogRow['TransactionLogID'] = self::$_TransactionID;
    
        $LogID = Gdn::SQL()->Insert('Log', $LogRow);
    
        if (self::$_TransactionID === TRUE) {
          // A new transaction was started and needs to assigned.
          self::$_TransactionID = $LogID;
          Gdn::SQL()->Put('Log', array('TransactionLogID' => $LogID), array('LogID' => $LogID));
        }
        }
      } else {
        if (self::$_TransactionID > 0)
        $LogRow['TransactionLogID'] = self::$_TransactionID;
    
        // Insert the log entry.
        $L = self::_Instance();
        $L->EventArguments['Log'] =& $LogRow;
        $L->FireEvent('BeforeInsert');
    
        $LogID = Gdn::SQL()->Insert('Log', $LogRow);
    
        if (self::$_TransactionID === TRUE) {
        // A new transaction was started and needs to assigned.
        self::$_TransactionID = $LogID;
        Gdn::SQL()->Put('Log', array('TransactionLogID' => $LogID), array('LogID' => $LogID));
        }
      }
      return $LogID;
    

    In your spare time, can you please consider a solution based on this? Thanks for your helpful input yet again. :)

  • I don't have that version, and I would be hesitant to suggest a guess on a live database especially since I can't experiment on the code. But if I were going to experiment on a non-live database and I didn't care if things got corrupted from a mistake I would comment out lines 30 and 35 and see what happens.

    As for logging - on the version I have anybody who edits or deletes a message gets the old message logged, so it can be retrieved.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I think I will let it be for now. I will see if it proves useful as my forum gets busier. Thanks for the help peregrine!

  • peregrine said:
    @badlearner

    Since the newer vanilla does indeed store revisions and deletions of comments

    Whoops I was wrong. Thanks for the help peregrine

    There was an error rendering this rich post.

  • No problem. Since its only viewable from profile 1 and only in the newer versions, its easy to overlook unless you look at all the tables in the database.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.