Drupal version: 8.0.0-beta15
Drush version: 8.0-dev

Enabling the module via Drush results in the following error.

PHP Fatal error:  Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface in /Users/huijing/Sites/drupal8.dev/core/lib/Drupal/Component/DependencyInjection/Container.php on line 265

Fatal error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface in /Users/huijing/Sites/drupal8.dev/core/lib/Drupal/Component/DependencyInjection/Container.php on line 265
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Cannot instantiate interface
Drupal\Core\Cache\CacheBackendInterface in
/Users/huijing/Sites/drupal8.dev/core/lib/Drupal/Component/DependencyInjection/Container.php,
line 265

Re-running the command drush en admin_menu -y outputs the following message:

admin_menu is already enabled.                                       [ok]
There were no extensions that could be enabled.

However, loading the site results in the following WSOD error message:
Fatal error: Call to undefined function user_access() in ../Sites/drupal8.dev/modules/admin_menu/admin_menu.module on line 149

Comments

huijing created an issue. See original summary.

huijing’s picture

Issue summary: View changes
2pha’s picture

I just installed a new D8 site and came across this.

for CachBackendInterface error, in .yml files (admin_menu.services.yml)
this:
factory_service: cache_factory
needs to change to:
factory: cache_factory:get

!user_access('access administration menu')
needs to change to:
!\Drupal::currentUser()->hasPermission('access administration menu')

$current_path = current_path();
changes to:
$current_path = \Drupal::request()->getRequestUri();

I then hit another error with drupal_http_build_query() and gave up.

EDIT:
Then tried to uninstall and got Call to undefined function variable_del()
:(

HongPong’s picture

Also had this happen on a plain new site, very first thing: drush dl admin_menu; drush en admin_menu

Also get probably related to note above:

Fatal error: Call to undefined function user_access() in /modules/admin_menu/admin_menu.module on line 149

sylvain lavielle’s picture

Got that too

HongPong’s picture

I took a shot at rolling a patch for the notes from @2pha above . Also I put a todo on the .install which has the deprecated variable_set, someone needs to decide on a name for the Config object involved as specified here: https://www.drupal.org/node/1667896 {not sure if the patch formatting is ok, i created it out of a commit instead of the correct way}. for more see #2401457: replace system variables with configuration API

I don't know if we have the right cache factory setting yet. After making these changes I got in drush attempting to enable:

exception [error] 'Symfony\Component\DependencyInjection\Exception\RuntimeException'
with message 'A service ("cache.admin_menu") can use either the old or the new factory syntax, not both.' in
/drupal-8.0.0-beta15/core/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php:54 

The code for that exception is here.

Anyway at least the patch gets rid of the fatal errors! Also I am setting this as a child issue of the overall 8.x meta issue #2398395: [meta] Port Admin Menu to Drupal 8. Yayz, onwards.

damien_vancouver’s picture

variable_del() isn't there in Drupal 8 and so we also need to comment out those variable_del() calls or you get an error trying to uninstall.

Attached is the patch from #6 with the variable_del()'s commented out.

huijing’s picture

Applied patch #7 to the existing "broken" drupal 8 installation. Trying to load the site still gives a WSOD but with a different error message:
Fatal error: Call to undefined function drupal_http_build_query() in /Users/huijing/Sites/d8.dev/modules/admin_menu/admin_menu.module on line 178

HongPong’s picture

@huijing bartuc posted a patch a year ago to cover this: https://www.drupal.org/files/issues/drupal-http-build-query-fix-2284015.... at #2284015: Undefined function drupal_http_query. Might as well roll it in to ours now. Note the class must be explicitly included as well now.

Also there are replacements for variable_set() & variable_get() included in #2401457: replace system variables with configuration API . Since they haven't been committed yet maybe we should combine from all three threads to consolidate this?

HongPong’s picture

FileSize
3.36 KB
None View

Here is a patch that should include everything above in - also with the one on #2284015: Undefined function drupal_http_query doesn't apply cleanly so here it is. The module at least doesn't error out, we have to now add config settings back into it.

Also I caught another one, the Path core module is required or it fatals out. So I think I added that correctly to fancy new yaml format info.yml.

HongPong’s picture

HongPong’s picture

Title: PHP Fatal error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface » PHP Fatal errors: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface and others
joachim’s picture

There's already issues with patches for various things covered here, eg #2457801: Replace user_access function with Drupal::currentUser()->hasPermission method. Please search for existing patches and review them before filing new patches :)

HongPong’s picture

Good call @joachim, I posted a new patch there that only adds a fix for the fatal error they got (path module not required), it seems RTBC. It is a little bit tricky situation since there are several sources for fatal errors on head right now, so something's gotta get committed in order to make patches that move us out of fatals.

kmonty’s picture

Swetha Yarla’s picture

kappaluppa’s picture

Comment #15 says this is a duplicate, but is the duplicate only of the issue named in #13, or of all the various items covered in the patch named in #10. Did it come down to "Replace user_access function with Drupal::currentUser()->hasPermission method" being the main underlying issue?

niccottrell’s picture

I'm still getting this in the latest dev release from 2015-Mar-20 - has it come back - or was -dev never patched?

mangamike’s picture

I'm getting this error in a local install. Has this patch been applied to the latest stable release?

bradallenfisher’s picture

I just got this as well.

[vagrant@drupal8 default]$ drush dl admin_menu
Project admin_menu (8.x-3.x-dev) downloaded to /var/www/html//modules/admin_menu.                                                                                               [success]
Project admin_menu contains 3 modules: admin_menu_toolbar, admin_devel, admin_menu.
[vagrant@drupal8 default]$ drush en admin_menu_toolbar
The following extensions will be enabled: admin_menu_toolbar, admin_menu
Do you really want to continue? (y/n): y
Error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 265
Error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface in Drupal\Component\DependencyInjection\Container->createService() (line 265 of /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php).
Drush command terminated abnormally due to an unrecoverable error.                                                                                                              [error]
[vagrant@drupal8 default]$ drush cr
PHP Fatal error:  Uncaught Error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:265
Stack trace:
#0 /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(181): Drupal\Component\DependencyInjection\Container->createService(Array, 'cache.admin_men...')
#1 /var/www/html/core/lib/Drupal/Core/Cache/Cache.php(163): Drupal\Component\DependencyInjection\Container->get('cache.admin_men...')
#2 /var/www/html/core/includes/utility.inc(44): Drupal\Core\Cache\Cache::getBins()
#3 /home/vagrant/.config/composer/vendor/drush/drush/commands/core/cache.drush.inc(291): drupal_rebuild(Object(Composer\Autoload\ClassLoader), Object(Symfony\Component\HttpFoundation\Request))
#4 /home/vagrant/.config/composer/vendor/drush/drush/includes/command.inc(366): drush_cache_rebuild()
#5 /home/vagrant/.config/composer/vendor/drush/drush/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
#6 /home/vagrant/.config/composer/vendor/drus in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 265
Drush command terminated abnormally due to an unrecoverable error.                                                                                                              [error]
Error: Uncaught Error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:265
Stack trace:
#0 /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(181): Drupal\Component\DependencyInjection\Container->createService(Array, 'cache.admin_men...')
#1 /var/www/html/core/lib/Drupal/Core/Cache/Cache.php(163): Drupal\Component\DependencyInjection\Container->get('cache.admin_men...')
#2 /var/www/html/core/includes/utility.inc(44): Drupal\Core\Cache\Cache::getBins()
#3 /home/vagrant/.config/composer/vendor/drush/drush/commands/core/cache.drush.inc(291): drupal_rebuild(Object(Composer\Autoload\ClassLoader),
Object(Symfony\Component\HttpFoundation\Request))
#4 /home/vagrant/.config/composer/vendor/drush/drush/includes/command.inc(366): drush_cache_rebuild()
#5 /home/vagrant/.config/composer/vendor/drush/drush/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
#6 /home/vagrant/.config/composer/vendor/drus in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php, line 265
[vagrant@drupal8 html]$ drush cr
PHP Fatal error:  Uncaught Error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:265
Stack trace:
#0 /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(181): Drupal\Component\DependencyInjection\Container->createService(Array, 'cache.admin_men...')
#1 /var/www/html/core/lib/Drupal/Core/Cache/Cache.php(163): Drupal\Component\DependencyInjection\Container->get('cache.admin_men...')
#2 /var/www/html/core/includes/utility.inc(44): Drupal\Core\Cache\Cache::getBins()
#3 /home/vagrant/.config/composer/vendor/drush/drush/commands/core/cache.drush.inc(291): drupal_rebuild(Object(Composer\Autoload\ClassLoader), Object(Symfony\Component\HttpFoundation\Request))
#4 /home/vagrant/.config/composer/vendor/drush/drush/includes/command.inc(366): drush_cache_rebuild()
#5 /home/vagrant/.config/composer/vendor/drush/drush/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
#6 /home/vagrant/.config/composer/vendor/drus in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 265
Drush command terminated abnormally due to an unrecoverable error.                                                                                                              [error]
Error: Uncaught Error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:265
Stack trace:
#0 /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(181): Drupal\Component\DependencyInjection\Container->createService(Array, 'cache.admin_men...')
#1 /var/www/html/core/lib/Drupal/Core/Cache/Cache.php(163): Drupal\Component\DependencyInjection\Container->get('cache.admin_men...')
#2 /var/www/html/core/includes/utility.inc(44): Drupal\Core\Cache\Cache::getBins()
#3 /home/vagrant/.config/composer/vendor/drush/drush/commands/core/cache.drush.inc(291): drupal_rebuild(Object(Composer\Autoload\ClassLoader),
Object(Symfony\Component\HttpFoundation\Request))
#4 /home/vagrant/.config/composer/vendor/drush/drush/includes/command.inc(366): drush_cache_rebuild()
#5 /home/vagrant/.config/composer/vendor/drush/drush/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
#6 /home/vagrant/.config/composer/vendor/drus in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php, line 265
MattMeadows’s picture

Getting this same issue.

Seemed to only occur after installing admin_menu module.

Following apache errors are output:

Cannot instantiate interface Drupal\\Core\\Cache\\CacheBackendInterface in /core/lib/Drupal/Component/DependencyInjection/Container.php on line 268

2pha’s picture

There have still been no commits since March 2015 so none of these patches have been applied.

alokvermaei’s picture

Yes i have got the same after enabling admin menu module. the problems seems on line 153 (hook implemented for page bottom).

kclarkson’s picture

I am lost on this issue. I tried applying the @HongPong's patch to the git 8.x-3.x but am still receiving errors.

Can someone let me know what patches I have to apply if this is already fixed.

rodtatham’s picture

@kclarkson, I followed @milazi's steps (look for #19 here -
https://www.drupal.org/node/2259267).

Worked for me!

aditya.n’s picture

Status: Closed (duplicate) » Needs work

I am changing the status back to needs work, since the duplicate issue tagged, does not cover this issue completely and the bug still persists.

aditya.n’s picture

I have removed most of the deprecated code off the module and used the drupal's 8.2.x's standard functions, also I have changed

factory_method: get
   factory_service: cache_factory

Which seemed to produce this particular issue(2563867).
Submitting the patch with other changes aswel.

Status: Needs review » Needs work

The last submitted patch, 27: admin-menu-php-fatal-errors-2563867-27-8.3.x.patch, failed testing.

HongPong’s picture

@aditya.n this patch #27 looks like a good start, I wish it would be committed and then further development would be much easier to figure out.

aditya.n’s picture

@HongPong, yes, but still a lot of work will be required, the hook_theme() used in drupal 8 now requires twig files with the name of the keys of the array defined in hook_theme(). Without that, the menu won't render at all, so new files also need to be added and a lot of code needs to be changed. Hope the maintainers find this patch helpful. :)

awelch’s picture

I just got the same error on install

Error: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface

and attempted uninstall via drush :

Error: Call to undefined function variable_del()

cilefen’s picture

Priority: Normal » Major

This is at least major, and perhaps critical.

vmamidela’s picture

Hi,

I'm using admin_menu module, after applying above patch, it stopped above error, however I'm seeing below error now .
Uncaught PHP Exception Twig_Error_Loader: "Template "profiles/test_profile/modules/contrib/admin_menu/templates/admin-menu-links.html.twig" is not defined (Drupal\\Core\\Template\\Loader\\ThemeRegistryLoader: Unable to find template "profiles/test_profile/modules/contrib/admin_menu/templates/admin-menu-links.html.twig" in the Drupal theme registry.)." at /var/www/sites/drupal/docroot_drupal_core_1910201629/vendor/twig/twig/lib/Twig/Loader/Chain.php line 115

Could you help me where can I find admin-menu-links.html.twig template for admin_menu module.

2pha’s picture

I have switched to using the Admin Toolbar module instead

bdanin’s picture

I agree that admin_toolbar is the way to go for Drupal 8

sandramandy’s picture

Disable the admin_menu doesn't solve this. Tried it but still got the fatal error. Any solutions to this issue?

beautifulmind’s picture

The best we can do is remove this module. If you try to uninstall it, it will throw more errors.

rmfranciacastillo’s picture

I've got this same error when installed the module on a fresh installation using drush 8.1.9

When tried to uninstall it, I've got the variable_del() not found.

In the end, I decided to use admin_toolbar module and eliminate the errors by removing the directory from modules/. Works as a this module is expected to work.