How does one clear the maillog? Do you just truncate a particular table?
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | clear_maillog-1421886-25.patch | 2.11 KB | robcarr |
| #24 | clear_maillog-1421886-24.patch | 2.45 KB | rick hood |
| #21 | 1421886-clear-maillog.patch | 2.24 KB | jstamper |
| #17 | interdiff-clear_maillog-1421886-13-17.txt | 1.6 KB | edurenye |
| #17 | clear_maillog-1421886-17.patch | 4.09 KB | edurenye |
Comments
Comment #1
rickmanelius commentedThat would be awesome... I'd like to flush for development purposes.
Comment #2
miro_dietikerMight be a button on the admin settings page. Pushing into current feature branch.
Currently, just flush the table of maillog.
Comment #3
chrisjlee commented@miro dietiker Is there a specific table or tables that one should flush?
Comment #4
miro_dietikerTable name is {maillog}
Comment #5
pluess commentedThis little patch addes a "Clear all maillog entries" button to the admin panel.
Comment #6
jkingsnorth commentedSince this is a destructive action shouldn't there also be a confirmation step?
Comment #7
miro_dietikerUse the common Drupal core confirm_form pattern:
https://api.drupal.org/api/drupal/modules%21system%21system.module/funct...
Comment #8
waverate commentedIt would be great to have this feature request implemented.
Comment #9
waverate commentedPatch #5 didn't clear the table me in D7.36 and maillog-7.x-1.x-dev.
From function db_truncate, it looks like you need to call execute on the object.
The following worked for me:
Comment #10
rhabbachi commentedRe-rolled the patch with the suggestion from #9
Comment #11
dkinzer commentedJust tried the patch at #10 locally and it works. We'll be using it in or testing environment.
Comment #12
miro_dietikerAs stated, It's a delete everything functionality, so we want to have a confirmation form. We won't add this without confirmation.
Let's have it in 8.x first.
Comment #13
edurenye commentedDone with confirmation and added tests.
Comment #15
miro_dietikerYeah thx, this looks nice to me!
Comment #16
rosk0Should be $this->t(), no?
Same as above.
Same.
Same.
Comment #17
edurenye commentedDone those changes.
Comment #18
miro_dietikerCommitted, thx!
The question mark was missing in the question sentence.
Comment #21
jstamper commentedI've created a D7 patch for this using confirm_form. If you want me to open a new issue I can do that.
Comment #22
spanners commentedTried applying patch from #21 and got...
The .rej file contains...
***************
*** 138,143 ****
}
/**
* Display a maillog record.
*
* @param array $maillog
--- 148,173 ----
}
/**
+ * Confirm form that deletes all entries from the maillog table
+ */
+ function maillog_maillog_clear_log_form($form, &$form_state) {
+ $question = t('Are you sure you want to clear all the maillog entries');
+ $path = 'admin/config/development/maillog';
+ $description = t('All maillog database entries will be deleted. This action cannot be undone.');
+
+ return confirm_form($form, $question, $path, $description);
+ }
+
+ /**
+ * Confirm form that deletes all entries from the maillog table
+ */
+ function maillog_maillog_clear_log_form_submit($form, &$form_state) {
+ db_truncate('maillog')->execute();
+ drupal_set_message(t("All maillog entries have been deleted."));
+ drupal_goto('admin/config/development/maillog');
+ }
+
+ /**
* Display a maillog record.
*
* @param array $maillog
Comment #23
waverate commentedPatch #21 applies cleanly to 7.x-1.x-dev (21 May 2016).
However, there is a typo on line 128; missing $:
It should read
Comment #24
rick hood commentedI lost the clear all maillog button after updating to this release: https://www.drupal.org/project/maillog/releases/7.x-1.0-rc1
I was able to add it back using code from #21 1421886-clear-maillog.patch
I created a patch with those changes.
It applied OK for me to 7.x-1.0-rc1 using git apply clear_maillog-1421886-24.patch
Comment #25
robcarrWhat a great patch. A site of mine kept crashing because the database was about 80Mb (should be just a few Mb) and MySQL kept running out of memory . The maillog table was most of that bulk and now works fine on 7.x-1.0-rc1
I rerolled the patch that Rick rolled at #24 to strip the file path down (it wouldn't apply as I don't put my Drupal site under /docroot)
Comment #26
robcarrI've created a separate issue so that the 7.x patch can be reviewed and committed #3187649: Truncate Maillog Table
Comment #27
bardiuk commentedFor whoever who will google this like me: https://www.drupal.org/project/maillog/issues/3341880
The list is a separate thing and the configuration is at the other page. In the configuration you can delete logs.
Configuration > Development > Maillog settings