I am creating two custom content type with reference to these pages:
https://www.drupal.org/node/2629550
https://www.drupal.org/node/2693979
Everything works fine. Content type with fields is created. But While installing, it throws an exception and as a result hook_install is not executing, i think. The error is as follows:
Uncaught PHP Exception Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: "You have requested a non-existent service "router.route_provider.old". Did you mean one of these: "router.route_provider", "router.route_preloader"?" at ...\\core\\lib\\Drupal\\Component\\DependencyInjection\\Container.php line 157
Could anyone please help me, why this is happening and how to fix it ?
I am using Drupal 8.1.8 version.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 2788087-30.patch | 2.66 KB | alexpott |
| #30 | 25-30-interdiff.txt | 856 bytes | alexpott |
| #25 | 2788087-24.patch | 2.66 KB | alexpott |
| #25 | 2788087-24.test-only.patch | 1.53 KB | alexpott |
| #7 | 2788087-7.patch | 1.1 KB | dawehner |
Comments
Comment #2
shafiqhossain commentedComment #3
shafiqhossain commentedI checked in core.services.yml file, there is no route declared as "router.route_provider.old"
Comment #4
shafiqhossain commentedI have created a router names as "router.route_provider.old" by copying "router.route_provider" in the core.services.yml file, which solves my problem.
i think Drupal uses "router.route_provider.old" router as a temporary to copy "router.route_provider" router info. But as this router name is not exists, its throwing exception.
I don't know if this is a bug or there is better way to fix it.
Comment #5
dawehnerThank you for reporting this issue. This is certainly interesting
Can you show your exact code you try to use? In theory the router.route_provider.old should be always available, but well, maybe you cause a container rebuild in your
hook_install()code which could cause this issue.Comment #6
shafiqhossain commentedHere is my hook_install() function. Its creating 2 terms and clear the cache, that's all.
Is clearing the cache creating the issue ?
Comment #7
dawehner@shafiqhossain
Yeah this probably causes the issue.
Do you mind trying out the patch from below? It should fix the issue, ideally.
Comment #8
shafiqhossain commentedYes the patch working well and fixes the issue. Thank you.
Comment #9
alexpott@shafiqhossain - you shouldn't be clearing the cache like that during a module install though. It's just not necessary.
Comment #10
shafiqhossain commentedUnless I clear the cache after installation, my new content types are not displaying in the content type list. In order to see the new content types in the list, I have to manually clear the cache from Performance page.
Comment #11
dawehner@shafiqhossain
Do you mind uploading the entire module? This would be super helpful for debugging reasons.
Comment #12
shafiqhossain commentedIts here:
https://github.com/shafiqhossain/adplus
Comment #13
thursday_bw commentedHad the same issue when calling
\Drupal::service('module_installer')->uninstall(['search']);uninstall fromhook_install()patch #7 does the trick.. Looks like a simple fix.
Comment #14
dawehnerIMHO it should be possible to write a test for that.
Comment #15
catchYes it should.
Comment #16
fizk commentedI just ran into this as well. I was trying to uninstall the Drupal-core Search module in
hook_install():Comment #17
web-beestI ran into this issue (Drupal 8.3.1) as well.
I have a hook_install that disables another modules which generated the error.
I can confirm this patch works for me.
Comment #18
kamkejj commentedAlso ran into this on 8.3.x with a install profile that's enabling modules in the .install file. The patch did work.
Comment #19
eclipsegc commentedNot plugin related
Comment #20
slydevil commentedPatch from #7 works for me as well.
Comment #21
phjouThe patch #7 is working for me too.
Comment #22
timodwhit commentedJust had to apply patch with the 8.4.5 update. Bumping version #
Comment #23
timodwhit commentedComment #24
alexpottSetting to correct core version.
Comment #25
alexpottHere's a test.
Comment #26
alexpott@shafiqhossain I cannot reproduce the behaviour of the content type list not being updated after install when node types are created. I've tested both with node_test_config and your module. As stated before called drupal_flush_all_caches() during a module install is not recommended.
Comment #28
tr commentedNice. The test reproduces the error, and the patch solves the problem.
I have encountered this several times in core 8.4.x and 8.5.x, and now 8.6.x. I can't work around it in my own code because it is being caused by my module's dependencies.
I have been using the patch in #7 for about four months now and it has solved the problem.
Comment #29
dawehnerComment #30
alexpottNoticed a comment length issue.
Comment #32
catchCommitted 7d18acf and pushed to 8.6.x. Thanks!
Moving to 8.5.x for backport once 8.5.0 is out.
Comment #34
catchForgot we'd decided on normal patch release rules during RC, so this is fine for 8.5.0, cherry-picked the commit.
Comment #36
kumar ashutosh commentedI used to upgrade core from 10.2.4 to 10.2.5 and getting this error.
So, I have downgraded the core version from 10.2.5 to 10.2.4 and it works like a charm for me.
Comment #37
albertho425I updated token to 1.14.0, diff to 1.3.0, search_api to 1.34.0, and search_api_solr to 4.3.3 on my main site which is working normally. On all my multisites, I see this message in Terminal.
ID Date Type Severity Message
------- -------------- -------------------- ---------- -------------------------------------------------------------------------------
18676 16/Apr 07:54 php Error Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You
have requested a non-existent service "token.module_provider". Did you mean
this: "router.route_provider"? in
18675 16/Apr 07:54 access denied Warning Path: /cehe/admin/reports/dblog?severity%5B%5D=3&severity%5B%5D=4.
Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException: The 'access
site reports' permission is required. in Drupa
18674 15/Apr 18:56 php Error Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You
have requested a non-existent service "token.module_provider". Did you mean
this: "router.route_provider"? in
Comment #38
albertho425Update:
Method: 1
Re-importing the database for each multisite resolves the issue.
Method: 2
1)
drush @site watchdog-show(to view errors because I could not access the UI)2)
drush @site updb -y(to run database script without an interaction)3)
drush @site cr(to clear the cache)Method: 3
When there are many multi-sites, run a loop for each of the above to save typing, especially when UI is not available
Comment #39
natefollmer commented@kumar-ashutosh I had the same error. You may want to check if you have any database updates pending. Search API had a pending DB update. After I ran drush updb, then the error you are seeing was resolved.
Comment #40
thirstysix commentedYeah it's working after database updates.