/**
  *	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!
  *
  *	FIXME: The code below is wrong. Do what it says above.
  *  FIXME: The hook for this file has not been added to ApprovedRevs.php
  *  FIXME: Create ApprovedRevs::UnsetApprovedFileBySha1 or something like that
  *     Compare UnsetApprovedFileInDB() and UnsetApprovedFile()
  **/
 public static function onFileDeleteComplete(File $file, $oldimage, $article, $user, $reason)
 {
     $dbr = wfGetDB(DB_SLAVE);
     // check if this file has an approved revision
     $approved_file = $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 ($approved_file) {
         $revs = array();
         $approved_exists = 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() == $approved_file->approved_timestamp && $OldLocalFile->getSha1() == $approved_file->approved_sha1) {
                 $approved_exists = true;
             }
         }
         if (!$approved_exists) {
             ApprovedRevs::UnsetApprovedFileInDB($file->getTitle());
         }
     }
     return true;
 }