Closed (won't fix)
Project:
Drush
Version:
8.x-6.x-dev
Component:
Core Commands
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Jul 2012 at 19:59 UTC
Updated:
11 Sep 2013 at 11:27 UTC
I found a need to delete all watchdog entries before a certain date in a multisite setup.
I therefore contribute this trivial patch I wrote to commands/core/watchdog.drush.inc
diff watchdog.drush.inc watchdog.drush.inc.delete_before
63a64
> 'drush watchdog-delete --before=YYYY-MM-DD[ HH:II:SS]' => 'Delete all messages with a timestamp before the given date[time] as defined by http://dev.mysql.com/doc/refman/5.5/en/datetime.html',
283a285,297
> elseif ( ($before = drush_get_option('before')) ) {
> drush_print(dt('Watchdog messages before !before will be deleted.', array('!before' => $before)));
> //@TODO validate the input using drush/drupal standard function, instead of this, which at least sanitizes for SQL
> if (!preg_match('|^[0-9-]{4,10} ?[0-9:]{2,10}$|', $before)){
> return drush_set_error(dt('Watchdog before !before option invalid date', array('!before', $before)));
> }
> if(!drush_confirm(dt('Do you really want to continue?'))) {
> return drush_user_abort();
> }
> $where = " unix_timestamp(!before) < timestamp ";
> $affected_rows = drush_db_delete('watchdog', $where, array('before' => $before));
> drush_log(dt('!affected_rows watchdog messages before !before deleted.', array('!affected_rows' => $affected_rows, '!before' => $before)), 'ok');
> }
Comments
Comment #1
greg.1.anderson commentedThis issue was marked
closed (won't fix)because Drush has moved to Github.If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to
closed (duplicate).Please ask support questions on Drupal Answers.