0
votes

have a module called phys_custom which defines a route, phys_custom.homepage (/homepage), which works fine, until I clear the cache, at which point it is no longer available.

Take a look at the following output. For now I need to always uninstall and reinstall my module every time I clear my cache. How would I go about debugging this?

$ drush @stewardd8.test -l phys cr
[success] Cache rebuild complete.
$ drush @stewardd8.test -l phys pmu phys_custom
[success] Successfully uninstalled: phys_custom
$ drush @stewardd8.test -l phys pm:enable phys_custom
[success] Successfully enabled: phys_custom
$ drush @stewardd8.test -l phys ev 'print_r(drupal_get_path("module", "phys_custom") . PHP_EOL)'
sites/phys/modules/phys_custom
$ drush @stewardd8.test -l phys ev 'print_r(\Drupal\Core\Url::fromRoute("phys_custom.homepage")->toString() . PHP_EOL)'
/homepage
$ drush @stewardd8.test -l phys cr
[success] Cache rebuild complete.
$ drush @stewardd8.test -l phys ev 'print_r(drupal_get_path("module", "phys_custom") . PHP_EOL)'
sites/phys/modules/phys_custom
$ drush @stewardd8.test -l phys ev 'print_r(\Drupal\Core\Url::fromRoute("phys_custom.homepage")->toString() . PHP_EOL)'

In RouteProvider.php line 201:

 Route "phys_custom.homepage" does not exist.  

I am using drush 9.6.2 and Drupal 8.6.15

I also opened an issue on Drupal.org

2

2 Answers

1
votes

This is actually a core bug currently being worked on, Extensions in Multisite Directories Not Registered When Rebuilding Cache . The patch there fixes the issue.

0
votes

This -l phys part in your command may be the cause of the issue.

Drush -l option purpose is to target a particular site in a multisite installations, it expects a URI :

-l <uri> , --uri=<uri> URI of the Drupal site to use. 
 The value of --uri should always be the same as when
 the site is being accessed from a web browser (e.g. http://example.com)

That said, you shouldn't have to specify it as soon as the alias @stewardd8.test is well defined, by which I mean at least these 2 options appear in the corresponding site alias definition :

test:
  root: /path/to/stewardd8
  uri: http://example.com

With these options set correctly, you can run drush status and check the output :

$ drush @stewardd8.test status
Drupal version                  :  8.6.14
Site URI                        :  http://example.com    # <- as expected

But, if you override the site URI with -l phys things may not work as expected :

$ drush @stewardd8.test -l phys status
Drupal version                  :  8.6.14
Site URI                        :  phys                  # <- invalid

So I suggest you start fixing this before digging further. Also you can add the -v, --verbose option to make drush more wordy, e.g. drush -v @stewardd8.test cr.

Then if it doesn't fix the missing route issue, I would scrutinize Drupal/PHP/SQL logs (in that order) especially when running the cache rebuild command.