Page not working anymore after installing uc_stock.

Clean install on LEMP
nginx version: nginx/1.4.6 (Ubuntu)
mysql Ver 14.14 Distrib 5.5.44, for debian-linux-gnu (x86_64) using readline 6.3
PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul 2 2015 15:23:08)

Modules installed over drush :
Drupal normal install (completely fresh)
UC non-optional coremodules
uc_stock

Error:
/var/log/nginx/error.log
2015/08/31 10:50:42 [error] 17939#0: *11468 FastCGI sent in stderr: "PHP mess
age: Uncaught PHP Exception Symfony\Component\Routing\Exception\RouteNotFound
Exception: "Route "uc_stock.reports" does not exist." at /var/www/mr2/core/li
b/Drupal/Core/Routing/RouteProvider.php line 176" while reading response head
er from upstream, client: xxx.xxx.xxx.xxx , server: my.domain.ch, requ
est: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MajorTwip created an issue. See original summary.

MajorTwip’s picture

Enabling uc_report solves the problem

Please add uc_report to the depencies of uc_stock.

TR’s picture

Priority: Major » Minor
Status: Active » Postponed (maintainer needs more info)

We definitely don't want uc_report to be a dependency of uc_stock.

The route itself is defined with a dependency in uc_stock.routing.yml, so that uc_stock.reports doesn't exist unless the uc_report module is enabled:

uc_stock.reports:
  path: '/admin/store/reports/stock'
  defaults:
    _controller: '\Drupal\uc_stock\Controller\StockReports::report'
  requirements:
    _module_dependencies: 'uc_report'
    _permission: 'view reports'

The uc_stock.reports route isn't referred to anywhere else but in uc_stock.links.menu.yml. I would have thought Drupal core would properly handle that, but I guess not.

Where does that error show up - on a page, or just in the logs? When does it happen? Maybe the _module_dependencies key can be used in the links.menu.yml, or maybe this needs a core patch to propagate the dependency.

TR’s picture

This appears to be the same as the issue raised in core: #2315801: Generating a local task based on a missing route causes a crash

MajorTwip’s picture

It appears immediately after enabling the module (without uc_report enabled) on every access.
I tried with a clean setup, no products added.

longwave’s picture

I can reproduce this, it's not quite the same as #2315801: Generating a local task based on a missing route causes a crash as uc_stock.reports is a normal menu item and not a local task. The cause appears to be toolbar.module attempting to render menu subtrees without paying attention to the module requirements. This still needs to be fixed in core rather than Ubercart.

TR’s picture

#2315801: Generating a local task based on a missing route causes a crash Does mention that the problem occurs with menu items and that the solution should address that as well.

longwave’s picture

Status: Postponed (maintainer needs more info) » Active

Oh, I didn't read the issue closely enough to spot that. In that case it seems like we could implement hook_menu_links_discovered_alter() similar to dblog_menu_links_discovered_alter() rather than include the link in uc_stock.links.menu.yml, but this still feels like a core bug rather than something we should work around.

david.czinege’s picture

Status: Active » Needs review
FileSize
1.18 KB

I fixed this issue.
I implemented the hook_menu_links_discovered_alter() inside the uc_stock.module file.

Inside this hook the uc_stock.reports route is checked, that it is available or not.
If it's available the Stock reports menu link is added under the Store / Reports menu item.

ben.bunk’s picture

Status: Needs review » Reviewed & tested by the community

This patch worked for me.

TR’s picture

@ben.bunk: Can you try this patch instead and see if this one also works for you?

The attached patch takes a different approach. While #9 removes the route from uc_stock.routing.yml then uses hook_menu_links_discovered_alter() to conditionally add the route back in iff uc_report is enabled, my patch here in #11 leaves the route defined in uc_stock.routing.yml then deletes it in hook_menu_links_discovered_alter() if uc_report is not enabled.

The end result of the two patches should be the same - i.e. the route is only defined if uc_report is enabled, but with my patch here the route remains declared in uc_stock.routing.yml which I find valuable as documentation of the uc_stock functionality.

Status: Needs review » Needs work

The last submitted patch, 11: 2560279-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

TR’s picture

Status: Needs work » Needs review

(The test failure is due to a Drupal core regression with 8.5.x and has nothing to do with this patch.)

  • TR committed 0ce5235 on 8.x-4.x
    Issue #2560279 by TR, david.czinege: Route uc_stock.reports missing
    
TR’s picture

Status: Needs review » Fixed

Committed #11.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.