Using latest dev (today, January 14th), when I go to the edit page of a geofield field with Openlayer Widget, I get this:

Fatal error: Class 'GeometryCollection' not found in /sites/all/modules/openlayers/modules/openlayers_geofield/src/Plugin/Component/GeofieldWidget/GeofieldWidget.php on line 133

If I use the dev version before the latest, everything works.

PS. Seems to me that the issue is NOT that the composer dependency is wrong. It's that geophp ISN'T loaded at the time it's needed, although it's correctly installed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rollingnet created an issue. See original summary.

rsvelko’s picture

simple solution is to use the last OL module release - 7.x-3.1
this works I tested now.

Me too tried with the git clone of the latest OL dev but it gives this error you mention.

So I did this to my git repo - git checkout 7.x-3.1 and it works - effectively it is the same as downloading the rlease from the tar.gz at d.o.

Making sense ?

m.stenta’s picture

I haven't looked at the recent development - but maybe some of the files moved around. Did you try rebuilding the registry?

drush registry-rebuild

Pol’s picture

Hi,

Thanks for helping in the issue queue :-)

I'm quite busy rewriting Geocoder (https://github.com/drupol/geocoder) 2.x and things might be broken in Openlayers. Sorry for that.
I will fix everything for the 3.2 release at the end of the month, if everything goes well.

Thanks!

Pol’s picture

Here's the procedure to get this fixed. As you may have seen, there's a composer.json file in the openlayers_geofield submodule.
this files contains:

{
    "require": {
        "phayes/geophp": "^1.2"
    }
}

Basically, this file says that you need the geophp library in order to have a module working properly.

You could either download it manually and do your stuff alone (which is not recommended at all) OR you can download the newly added dependencies Composer Manager and do things properly.

There's a couple of extra steps, here's the full procedure to get everything working:

  1. drush dl composer-8.x
  2. drush composer-json-rebuild
  3. drush composer-manager install

Here's the log on my machine...

pol@x230 ~/d/s/d7x> rm -rf sites/all/libraries/composer
pol@x230 ~/d/s/d7x> drush dl composer-8.x-1.x
Project composer (8.x-1.x-dev) downloaded to /home/pol/.drush/composer.                                                                              [success]
Project composer contains 0 modules: .
pol@x230 ~/d/s/d7x> drush composer-json-rebuild
Completed building composer.json file.                                                                                                                                               [ok]
pol@x230 ~/d/s/d7x> drush composer-manager install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
  - Installing psr/http-message (dev-master 85d6369)
    Cloning 85d63699f0dbedb190bbd4b0d2b9dc707ea4c298

  - Installing zendframework/zend-diactoros (dev-develop c866b82)
    Cloning c866b82a964a82aaa40b971fd344f882ca9b92d9

  - Installing egeloen/http-adapter (dev-master f8514a0)
    Cloning f8514a0f23228087ac00d06e9a71533edcdf185c

  - Installing igorw/get-in (dev-master e2bfd52)
    Cloning e2bfd524906ba62fe03a80cd3efd3ec635850a1b

  - Installing phayes/geophp (1.2)
    Loading from cache

  - Installing symfony/http-foundation (dev-master 236178a)
    Cloning 236178a3d08f1adea6d30b6e06c0c35c0973046d

  - Installing symfony/polyfill-mbstring (dev-master d7f01c9)
    Cloning d7f01c96a4dde264682cf36c28e62086c77a09d4

  - Installing symfony/var-dumper (dev-master a774ede)
    Cloning a774edeee22c8c3db4e7dafdcedc4b2a3154eb8f

  - Installing willdurand/geocoder (dev-master 47baf0c)
    Cloning 47baf0c5a707f9324f4bcbc5e623308160274685

egeloen/http-adapter suggests installing doctrine/cache (Allows you to use the cache event subscriber)
egeloen/http-adapter suggests installing ext-http (Allows you to use the PECL adapter)
egeloen/http-adapter suggests installing guzzle/guzzle (Allows you to use the Guzzle 3 adapter)
egeloen/http-adapter suggests installing guzzlehttp/guzzle (Allows you to use the Guzzle 4 adapter)
egeloen/http-adapter suggests installing kriswallsmith/buzz (Allows you to use the Buzz adapter)
egeloen/http-adapter suggests installing nategood/httpful (Allows you to use the Httpful adapter)
egeloen/http-adapter suggests installing psr/log (Allows you to use the logger event subscriber)
egeloen/http-adapter suggests installing rmccue/requests (Allows you to use the Requests adapter)
egeloen/http-adapter suggests installing symfony/event-dispatcher (Allows you to use the event lifecycle)
egeloen/http-adapter suggests installing symfony/stopwatch (Allows you to use the stopwatch http adapter and event subscriber)
egeloen/http-adapter suggests installing tedivm/stash (Allows you to use the cache event subscriber)
egeloen/http-adapter suggests installing zendframework/zend-http (Allows you to use the Zend 2 adapter)
egeloen/http-adapter suggests installing zendframework/zendframework1 (Allows you to use the Zend 1 adapter)
symfony/var-dumper suggests installing ext-symfony_debug ()
willdurand/geocoder suggests installing ext-geoip (Enabling the geoip extension allows you to use the MaxMindProvider.)
willdurand/geocoder suggests installing geoip/geoip (If you are going to use the MaxMindBinaryProvider (conflict with geoip extension).)
willdurand/geocoder suggests installing geoip2/geoip2 (If you are going to use the GeoIP2DatabaseProvider.)
willdurand/geocoder suggests installing symfony/stopwatch (If you want to use the TimedGeocoder)
Package egeloen/http-adapter is abandoned, you should avoid using it. Use php-http/httplug instead.
Generating autoload files
pol@x230 ~/d/s/d7x>

EDIT: if you have troubles, check this issue : #2567885: Error creating directory: public://composer in composer_manager_file_dir(), there's a fix at the end.

Good luck.

Pol’s picture

rollingnet’s picture

As you can see, I installed geophp correctly following your indication,

Installation of geophp

but the error

Error: Class 'GeometryCollection' not found in Drupal\openlayers_geofield\Plugin\Component\GeofieldWidget\GeofieldWidget->initialDataToGeomFeatures() (line 133 of /Sites/peacock2/sites/all/modules/openlayers/modules/openlayers_geofield/src/Plugin/Component/GeofieldWidget/GeofieldWidget.php).

is still present

aDarkling’s picture

I also reinstalled phayes/geophp per the instructions and got good marks from both admin/reports/status and admin/config/system/composer-manager

The error's still there.

altbzh1’s picture

FileSize
142.82 KB
122.58 KB

Hi

It's absolute hell ... ti install this.

I have installed crush via composer, so I have already composer components :

  • vendor : /home/me/.composer/vendor
  • composer.son : /home/me/.composer

That's the settings I write in the Composer Manager settings.

Before I had many packages written in packages tap of component manager with drush "no longer required"component manager

I use enable openlayers_examples accept to update dependencies : geoPHP library is ok but I have no more Drush ...Component drush

So how do we have to do to keep it ?

Thank you

altbzh1’s picture

Hi

It's absolute hell ... ti install this.

I have installed crush via composer, so I have already composer components :

  • vendor : /home/me/.composer/vendor
  • composer.son : /home/me/.composer

That's the settings I write in the Composer Manager settings.

Before I had many packages written in packages tap of component manager with drush "no longer required"component manager

I use enable openlayers_examples accept to update dependencies : geoPHP library is ok but I have no more Drush ...Component drush

So how do we have to do to keep it ?

Thank you

Pol’s picture

Hi,

I know it's not easy especially when module are in dev.
I'm working on a solution, it might take a bit of time these days, I'm busy on something else right now.

I'll update this thread when I'll do something.

aDarkling’s picture

The geophp library isn't loaded.

Add geophp_load(); before that first call to the GeometryCollection class and everything should be all right.

Geofields also loads this library, so that's why the problem seems to go away sometimes.

rollingnet’s picture

I can confirm that inserting

geophp_load();

at line #133 of sites/all/modules/openlayers/modules/openlayers/src/Plugin/Component/GeofieldWidget/GeofieldWidget.php
solves this issue

by now, everything seems to work well with this patch

rsvelko’s picture

with the latest git version of OL3, the path is ./sites/all/modules/openlayers/modules/openlayers_geofield/src/Plugin/Component/GeofieldWidget/GeofieldWidget.php

other than that editing line 133 there and putting geophp_load(); on it worked fine here too.
I am using these modules - most of them via git latest dev
admin_menu
composer_manager
computed_field
ctools
elements
entity
feeds
gdal
geocoder
geofield
geofield_postgis
geophp
git_deploy
job_scheduler
jquery_update
libraries
module_filter
openlayers
postgis
README.txt
registry_autoload
service_container
sync_postgis
views
views_geojson

Syntapse’s picture

i eliminated this error by running composer install in the sites/all/modules/openlayers/modules/openlayers_geofield folder.

Possible that composer's dependency hierarchy is not correctly defined?

rsvelko’s picture

I dont know where is the best place for:

geophp_load();

but putting it anywhere I tried seems to work the same.

Here are two patches and lets review and commit sth similar.

rsvelko’s picture

Status: Active » Needs review

The last submitted patch, 16: openlayers-load-geophp-in-GeofieldWidget.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 16: openlayers-load-geophp-in-start-of-dot-module.patch, failed testing.