Problem/Motivation
Scheduler adds a default local task route for viewing the main content view because core doesn't. This is required because it adds a new local task for viewing scheduled content, and users will need to have the default one available as well so they can switch back to the main route.
Scheduler is not the only module that has this problem. The Content Moderation module also does, and adds the default route.
Scheduler tries to detect if there's another module providing the default route, and if there is, it removes its own so there aren't two. If even after doing that, there's still more than 1 default route, it logs a warning:
// If there is more than one for any of the routes being checked then remove
// the route added by Scheduler.
foreach ($found as $route => $data) {
if (count($data) > 1) {
unset($local_tasks[$data['scheduler']]);
unset($data['scheduler']);
}
// We assume that the duplicates are only caused by Scheduler. Other modules
// could be causing more so log this and solve it later if it ever happens.
if (count($data) > 1) {
\Drupal::logger('scheduler')->warning('Local task route %route contains duplicates in addition to Scheduler. %data', [
'%route' => $route,
'%data' => print_r($data, TRUE),
]);
}
}
This warning message actually creates a lot of noise in the logs for sites on a platform I maintain. We have a custom module that adds the default local task and removes the one provided by Scheduler and Content Moderation. Basically we're taking the problem into our own hands and removing all the duplicates from various contrib modules we support.
So on sites that have our custom module, Scheduler, and Content Moderation enabled, this warning message is triggered. I'd prefer if it didn't because it shows up in the logs on every cache clear.
Steps to reproduce
Enable multiple modules that provide the default local task for content overview, clear cache, and view watchdog logs.
Proposed resolution
Remove the warning message
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3388029-remove-duplicate-local-task-warning.patch | 708 bytes | bkosborne |
Issue fork scheduler-3388029
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bkosborneHaving trouble with gitlab branches. Here's an old fashioned patch...
Comment #3
jonathan1055 commentedHi bkosborne,
Is the hook_local_tasks_alter() called during install? Would there be a way to write this just once when Scheduler is installed? Then the code could be left in, but would not continually fill your log on clearing the cache.
Comment #5
jonathan1055 commentedMaybe we just remove that log message. I added it because I thought it would be helpful.
Comment #7
jonathan1055 commentedDecided to just remove the log warning. It is not really needed.
Merged and fixed. Thanks.