Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In Drupal 8.1.x (doesn't seem to happen in 8.0.x), when I enable Honeypot in the admin UI (modules/extend page), I see:
The website encountered an unexpected error. Please try again later.
In the logs:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "honeypot.config" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 191 of /var/www/drupalvm/drupal/core/lib/Drupal/Core/Routing/RouteProvider.php).
I seem to remember specifically fixing this bug elsewhere by switching the code in hook_install()
to use Url::fromUri
... but my memory is quite foggy on that at this point.
Here's the current code in 8.x-1.x:
/**
* Implements hook_install().
*/
function honeypot_install() {
if (PHP_SAPI !== 'cli') {
$config_url = Url::fromUri('base://admin/config/content/honeypot');
drupal_set_message(t("Honeypot installed successfully. Please @link to protect your forms from spam bots.", [
'@link' => \Drupal::l(t('configure Honeypot'), $config_url),
]));
}
}
Whatever the case, even though the module installs successfully, this error-on-install is quite jarring, and I'd like to get it fixed.
Comments
Comment #2
geerlingguy CreditAttribution: geerlingguy as a volunteer commentedAh, #2348503: Drupal::l() can't be used for internal paths in hook_install() - Symfony throws "Route does not exist" was the issue I was vaguely remembering...
Comment #3
geerlingguy CreditAttribution: geerlingguy as a volunteer commentedComment #4
geerlingguy CreditAttribution: geerlingguy as a volunteer commentedI'm probably hitting #2230091: Route rebuilding is not guaranteed to finish in time for the next request :(
Comment #5
mr.baileysHmmm, I'm unable to reproduce this on a stock D8.1 HEAD with Honeypot 8.x-1.x HEAD locally. I've also installed Honeypot on D8.1.x through Simplytest.me, and am not running into this problem there either. Are you using any non-default settings or services?
Comment #6
geerlingguy CreditAttribution: geerlingguy as a volunteer commentedHmm... Maybe I have something strange in my environment... I'll check into it and close if I can't reproduce.
Comment #7
geerlingguy CreditAttribution: geerlingguy as a volunteer commentedHuh... I must've had some weird state associated with one of my local VM installs, because after wiping everything and reinstalling/re-cloning core from scratch, it's working fine in
8.1.0-dev
and8.0.0-dev
.