When I try to run site update.php I get this error. Any I idea why?
Fatal error: Call to a member function get() on a non-object in /sites/all/modules/service_container/lib/Drupal.php on line 52

This happens when you install openlayers modules.

Comments

santhoshabraham’s picture

Issue summary: View changes
Issue tags: +openlayers
fabianx’s picture

I have not tested update.php, that is indeed a bug.

Can you try:

drush updb

instead?

santhoshabraham’s picture

I did little bit research, looks like service container need at least PHP >= 5.5. I'm running PHP 5.3. Is that cause the problem?
https://www.drupal.org/node/2443237

fabianx’s picture

It should not be, I have tests working around PHP 5.3.

santhoshabraham’s picture

I upgraded to php 5.6. Still having same issue.

fabianx’s picture

So does drush updb work? Or is it only update.php that breaks?

santhoshabraham’s picture

I tried drush updb, it works fine.

astringer’s picture

I am getting this error, also after an OpenLayers install. But I am getting the error in Views. It started as an ajax error:

AJAX http error 200

Fatal error: Call to a member function get() on a non-object in .../sites/all/modules/service_container/lib/Drupal.php on line 52

This occurred when I tried to edit the view. I save the view and exited and now I cannot get back into the view -- the error appears.

fabianx’s picture

Assigned: Unassigned » fabianx

Please give me as much information as you can in terms of how to reproduce. I will try to fix this ASAP.

astringer’s picture

I don't want to give it you from memory, so I'll need to reinstall the module. But I will get back to you.

m.stenta’s picture

Steps to reproduce:

  1. Install Service Container
  2. Go to update.php

You will see:

Fatal error: Call to a member function get() on a non-object in .../service_container/lib/Drupal.php on line 52
formatC'vt’s picture

update.php doesn't call service_container_init()
try openlayers latest dev

fabianx’s picture

Yes, I will need to see how I can get the service container registered during update.php

That will be fun! :)

robertwb’s picture

Should this be changed to "Postponed" since it maybe can be chalked up to the related problem with OpenLayers module? FWIW the new dev version of OL seemed to avoid this error (so far).

stevieb’s picture

I had the same issue ... I resolved it by running the update script before installing Openlayers and Service Container ... then everything works fine.

el_toro’s picture

Here's a quick hack that I used to get around this issue...

fabianx’s picture

Status: Active » Reviewed & tested by the community

That is a pretty good idea!

There is one caveat however - this can only work if the container was build already - as trying to build it in hook_boot() would have bad consequences atm. (https://www.drupal.org/node/496170):

- I will take a look, thanks for your patch!

pol’s picture

Hello,

In Openlayers, we've fixed the problem by adding two hooks:

/**
 * Implements hook_stream_wrappers_alter().
 */
function openlayers_stream_wrappers_alter(&$wrappers) {
  // Initialize the container. Ensure the class exists, necessary to ensure
  // a stall registry can be rebuild.
  if (class_exists('ServiceContainer')) {
    ServiceContainer::init();
  }
}

/**
 * Implements hook_enable().
 */
function openlayers_enable() {
  // Reset the container. Ensure the class exists, necessary to ensure
  // a stall registry can be rebuild.
  if (class_exists('ServiceContainer')) {
    ServiceContainer::reset();
  }
}

See the original issues: #2446309: update.php produces fatal error and #2468057: "openlayers.manager" service definition does not exist.

fabianx’s picture

Status: Reviewed & tested by the community » Fixed
fabianx’s picture

Title: Fatal error: Call to a member function get() on a non-object » Update the initialization and reset of the container

  • Fabianx committed 80d9755 on 7.x-1.x
    Merge pull request #22 from drupol/Initialization-and-reset-of-the-...

  • Fabianx committed 80d9755 on 8.x-1.x
    Merge pull request #22 from drupol/Initialization-and-reset-of-the-...
webengr’s picture

Should I go back to openlayers2 or try some of the patches, I am also as of 6/24 getting the error if I do a drush rr with all the latest dev

Error: Call to a member function get() on null in ............../sites/all/modules/service_container/lib/Drupal.php, line 52

fabianx’s picture

webengr’s picture

I applied the beta updates that were dated 6/25 for openlayers and the service_container,
now the openlayers 3 is doing something and yes the "--no-cache-clear" also was required to rebuild the registry

So yes the 6/25 update made something work better, yes the drush rr does not work if it is allowed to clear cache.
In Fabian's words "Nice! So without clearing cache a registry rebuild is more successful, that gives hope"

Status: Fixed » Closed (fixed)

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