I save a new view with geofield plugin and apache blocks the page when I try to load it.
all to a member function out() on a non-object in ./sites/all/modules/geofield/modules/geofield_map/includes/geofield_map_plugin_style_map.inc on line 118

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

phayes’s picture

Can you confirm that you have geoPHP installed and updated to the latest version by checking your status page?

Admdebian’s picture

I have the last version of geophp... How can I check?

Admdebian’s picture

excuseme..that's my status report:
GeoPHP Library Installed GeoPHP 0.5 library installed at sites/all/libraries/geoPHP/geoPHP.inc

Brandonian’s picture

The check for whether or not the geometry exists in question on line 115 in modules/geofield_map/includes/geofield_map_plugin_style_map.inc might not be enough. I'll see if I can reproduce.

Brandonian’s picture

Also, are you actually using 2.x-dev, or one of the 1.x releases?

Admdebian’s picture

I worked a lot with this project... when I have posted the bug, I was running the 7.x.2-dev as I wrote. Can I help you?

phayes’s picture

Hi Admdebian,

If you can, we really would appreciate you looking into this bug in the code. Please do and report back! Patches would also be appreciated.

kvit’s picture

I use textfield (for address input) + geocoder (Google) + geofield + geofield map to provide maps for content nodes and for views.
Everything was fine for me with Feb-09 geoPHP library, Jan-27 Geocoder 7.x-1.x-dev and Geofield 7.x-1.0-rc1.

Today I upgraded to Feb-25 geoPHP library and Feb-27 Geocoder 7.x-1.x-dev. After that:
- I see my content nodes without map;
- I see nothing on the pages that contain views using Geofield Map format except
"Fatal error: Call to a member function out() on a non-object in .../modules/geofield/modules/geofield_map/includes/geofield_map_plugin_style_map.inc on line 118"

Upgrading Geofield from rc1 to Feb-26 7.x-1.x-dev didn't help.

phayes’s picture

Can you try rolling back to the previous version of geoPHP?

kvit’s picture

With installing Geocoder 7.x-1.0-beta1 the problem disappeared.

Added:Than after 20 hours of normal work the error showed up again. It seems that it doesn't depend on the version of geoPHP, geofield or geocoder, and don't know why it appeares and disappeares.

nrambeck’s picture

I have the exact same problem. I'm using Geocoder with Address field and my view generates the same fatal error.

Attached is a patch that fixes the problem, but I'm not sure if this fix will break in other circumstances.

In my situation this line:

$geometry = geoPHP::load($geofield[0]['rendered']['#markup'], 'wkt');

Was using this actual data (not a WKT data format):

geoPHP::load('Longitude: 1.0000,<br />Latitude: 2.00000', 'wkt');
Brandonian’s picture

Good debugging, @nrambeck. I've committed your patch to the dev branches. The next time you commit a patch to a module, can you make it relative to the module rather than the root of your Drupal install?

@kvilt, can you confirm that this fix takes care of your problem?

nrambeck’s picture

Sorry about the sloppy patch file. I was under a time crunch. Here is a better patch file in case someone needs just this fix.

Admdebian’s picture

I don't use geocoder, I think that geocoder version can't solve the bug.

I'm glad to know someone made a patch; good work! I'll read your comments.

(Excuse me but I have no time now to work at the patch, I have problem vith views and openlayers...I think there is a new bug...)

kvit’s picture

Thanks for the work on the problem.
Installing Feb-29 dev of Geofield solved it for most of my views, though not all of them.
If some address input data is not accurate and can't be geocoded, the content node shows no map and it's OK. But a View containing this content still leads to Fatal error from #8. I would much prefer if erroneous addresses from content provided no points on the Geofield Map View instead of Fatal error. Otherwise any user adding not accurate address to a node can totally break views pages containing important data from other users.

mavdiablo’s picture

Component: GeoFied Map » Code

Hi there,
I have the same error
sites/all/modules/geofield/modules/geofield_map/includes/geofield_map_plugin_style_map.inc on line 118
in a page view using geofield map wkt
Furthermore, in the node page can not show a map of the address field.
All this worked before the upgrade to Drupal 7.14 on May 3
Have you some suggestion?

Drupa1ish’s picture

There are no controls available on node edit page after upgrading to Drupal 7.14

Brandonian’s picture

Status: Active » Fixed

Forgot to mark this fixed from earlier. Please reopen if anyone has the same issue.

Status: Fixed » Closed (fixed)

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

Dave Cohen’s picture

Status: Closed (fixed) » Active

I'm seeing this problem in a view block display of type geofield map.

The code looks like this:

          $geometry = geoPHP::load($geofield[0]['raw']['wkt'], 'wkt');                                                            
          $datum = json_decode($geometry->out('json'));

$geometry is null, which causes the fatal error.

$geofield[0]['rendered'] is set, but 'rendered' is the only key in $geofield[0]. There is no 'raw'.

mikemadison’s picture

Issue summary: View changes

I'm still getting this issue with the most recent dev:

Fatal error: Call to a member function out() on a non-object in /drupal/sites/all/modules/geofield/modules/geofield_map/includes/geofield_map_plugin_style_map.inc on line 121

After digging a bit, it actually looks fairly easy to fix.

if (!empty($geofield)) {
          $description = ($popup_data ? $this->rendered_fields[$id][$popup_data] : '');
          $geometry = geoPHP::load($geofield[0]['geom']);
          $datum = json_decode($geometry->out('json'));
          $datum->properties = array(
            'description' => $description,
          );
          $data[] = $datum;
        }

should be changed to

if (!empty($geofield[0]['geom'])) {
          $description = ($popup_data ? $this->rendered_fields[$id][$popup_data] : '');
          $geometry = geoPHP::load($geofield[0]['geom']);
          $datum = json_decode($geometry->out('json'));
          $datum->properties = array(
            'description' => $description,
          );
          $data[] = $datum;
        }
bmunslow’s picture

#21 worked for me, thanks!

piyuesh23’s picture

#21 works for me as well

mariacha1’s picture

Status: Active » Needs review
FileSize
824 bytes

Here's a patch that mimics comment #21, which also fixed the error for me.

eelkeblok’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, #24 works for me.

Brandonian’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch, @mariacha1! Committed to 7.x-2.x

http://drupalcode.org/project/geofield.git/commit/16a0335

Status: Fixed » Closed (fixed)

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

bendev’s picture

Against version 7.X-1.2, this would be

diff --git a/sites/all/modules/geofield/modules/geofield_map/includes/geofield_map_plugin_style_map.inc b/sites/all/modules/g
index fa7e087..fdfff98 100644
--- a/sites/all/modules/geofield/modules/geofield_map/includes/geofield_map_plugin_style_map.inc
+++ b/sites/all/modules/geofield/modules/geofield_map/includes/geofield_map_plugin_style_map.inc
@@ -123,7 +123,7 @@ class geofield_map_plugin_style_map extends views_plugin_style {
       foreach ($this->view->result as $id => $result) {
         $geofield = (!empty($result->$geo_data)) ? $result->$geo_data : NULL;

-        if (!empty($geofield[0]['geom'])) {
+        if (!empty($geofield[0]['raw']['wkt'])) {
           $description = ($popup_data ? $this->rendered_fields[$id][$popup_data] : '');
           $marker_type = ($marker_data ? $this->rendered_fields[$id][$marker_data] : '');
           $geometry = geoPHP::load($geofield[0]['raw']['wkt'], 'wkt');