/**
  *	If a file is deleted, check if the sha1 (and timestamp?) exist in the
  *  approved_revs_files table, and delete that row accordingly. A deleted
  *  version of a file should not be the approved version!
  **/
 public static function onFileDeleteComplete(File $file, $oldimage, $article, $user, $reason)
 {
     $dbr = wfGetDB(DB_SLAVE);
     // check if this file has an approved revision
     $approvedFile = $dbr->selectRow('approved_revs_files', array('approved_timestamp', 'approved_sha1'), array('file_title' => $file->getTitle()->getDBkey()));
     // If an approved revision exists, loop through all files in history.
     // Since this hook happens AFTER deletion (there is no hook before deletion), check to see
     // if the sha1 of the approved revision is NOT in the history. If it is not in the history,
     // then it has no business being in the approved_revs_files table, and should be deleted.
     if ($approvedFile) {
         $revs = array();
         $approvedExists = false;
         $hist = $file->getHistory();
         foreach ($hist as $OldLocalFile) {
             // need to check both sha1 and timestamp, since reverted files can have the same
             // sha1, but different timestamps
             if ($OldLocalFile->getTimestamp() == $approvedFile->approved_timestamp && $OldLocalFile->getSha1() == $approvedFile->approved_sha1) {
                 $approvedExists = true;
             }
         }
         if (!$approvedExists) {
             ApprovedRevs::unsetApprovedFileInDB($file->getTitle());
         }
     }
     return true;
 }