Prevent users from manually clearing dblog [Patch available]

Created on 9 December 2023, about 1 year ago
Updated 2 April 2024, 9 months ago

Problem/Motivation

I think this module should protect the records that it doesn't prune. I argue that the records that stay in the database are probably important.

So I think this module should protect against administrator truncating the watchdog table.

Steps to reproduce

  • Set up this module to prune the records that are not important (leaving the ones that are important)
  • Go to /admin/reports/dblog/confirm and submit the form
  • Note that the records that were important are gone

Proposed resolution

Throw access deined on the confirm form.

namespace Drupal\watchdog_prune\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

class DbLogRouteSubscriber extends RouteSubscriberBase {
  public function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('dblog.confirm')) {
      $route->setRequirement('_access', 'FALSE');
    }
  }
}

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇦🇺Australia sime Melbourne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024