Problem/Motivation

I would like to allow users to enter an Address using the Address module and have those geocoded and stored by Geofield. I'm trying out the geocoder-php/free-geoip-provider

Steps to reproduce

  1. Enable Address, Geocoder, and Geofield, setting FreeGeoIp as the only active provider.
  2. Enable Geocoder_Address
  3. Create an address field on a content type - options for geocoding appear
  4. Create a geofield field on the content type - no options, as expected
  5. Enable geocoder_geofield
  6. Revisit the geofield settings, or create a new new one - no geocoding options (I expected options to set this to store geocodes.)
  7. drush cr
  8. Revisit either the address field or geofield settings pages - fatal error: "Drupal\Component\Plugin\Exception\PluginNotFoundException: The "freegeoip" plugin does not exist. Valid plugin IDs for Drupal\geocoder\ProviderPluginManager are: random, file, kmlfile, geojsonfile, gpxfile in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of .../core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php)."

It appears that clearing the cache has made the system forgets that the freegeoip plugin exists and has defaulted back to the out-of-the-box plugins.

Disabling geocoder_geofield recovers functionality

Additional Information

I discovered that geocoder-php/free-geoip-provider doesn't work for my purposes, so decided to swap it out for geocoder-php/google-maps-provider.

  1. Disable all Geocoder-related modules stepwise, up to and including Geocoder itself, so that the new provider could be installed.(It is ludicrous that this is necessary in order to add or change providers.)
  2. composer require geocoder-php/google-maps-provider.
  3. Re-enable Geocoder
  4. Activate GoogleMaps Provider
  5. Re-enable Geocoder Field & Geocoder Geofield: The existing geocode field now shows options for storing geocodes from another field, but the Address field isn't one of them, presumably because Geocoder_Address isn't enabled yet.
  6. Enable Geocoder_Address: The existing Address field's edit page does not show options for geocoding. Attempting to visit the existing Geofield's edit page, or the edit page for the GoogleMaps Provider, kills the site with watchdog logging Drupal\Component\Plugin\Exception\PluginNotFoundException: The "googlemaps" plugin does not exist. Valid plugin IDs for Drupal\geocoder\ProviderPluginManager are: random, file, kmlfile, geojsonfile, gpxfile in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of .../core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
  7. Disabling Geocoder_Address recovers access to Geofield's and GoogleMaps' edit pages
  8. Reversing the order of enabling of the Geocoder_Address and Geocoder Geofield modules behaves the same way.

Proposed resolution

Clearing cache should not break basic functionality, and/or enabling both Geocoder_Address and Geocoder_Geofield shouldn't break it.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#14 Screenshot 2021-03-31 at 20.42.52.png265.02 KBitamair

Comments

msypes created an issue. See original summary.

msypes’s picture

Issue summary: View changes
msypes’s picture

Issue summary: View changes
itamair’s picture

Status: Active » Postponed (maintainer needs more info)

@msypes thanks for reporting your issue ...
But I cannot really replicate your issue. All looks working fine, with geocoder-php/free-geoip-provider and Geocoder_Geofield and all the other modules you mention. (@see my screenshots).

Did you forget to composer re-require the geocoder-php/free-geoip-provider library?

composer require geocoder-php/free-geoip-provider

You should better inspect and investigate/debug your case, and eventually prove (post evidence) of the application error log.

This should be proved (from you) to be a real bug (and not your personal issue in your dev environment)

itamair’s picture

May be I am wrong, but it indeed seems to me that you are not using at all the proper way to composer require new geocoder providers libraries according to the new 3.x Geocoder branch (may be you just upgraded from the 2.x branch?). Be sure to have read and understood the relevant instructions in the Readme.md file ... and may be go through this support issue: https://www.drupal.org/project/geocoder/issues/3128165

msypes’s picture

Issue summary: View changes
itamair’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
msypes’s picture

This is not an upgrade from a previous version of Geocoder. I have never used it before. This is a fresh install of v3.17 in a new vanilla D9 site.

I used composer to require all the necessary modules and each of the provider libraries prior to enabling any modules. The rest of the steps I have clearly outlined step-by-step. I do not see any difference in the ordering of my steps from the README file. Please tell me what it is about those steps that indicate to you that I'm "not using at all the proper way to composer require new geocoder providers libraries according to the new 3.x Geocoder branch."

itamair’s picture

Simply from its readme.md file: https://git.drupalcode.org/project/geocoder/-/blob/8.x-3.x/README.md

The external Geocoder Provider(s)
that should enabled and used in the module ....

Choose the Geocoder Provider
you want to use and also add it as a required dependency to your project. For
example if you want to use Google Maps as your provider:
$ composer require geocoder-php/google-maps-provider

msypes’s picture

That is exactly what I did, as noted in my post. I've tried both FreeGeoIP and GoogleMaps providers, requiring them via composer before enabling Geocoder. If both Geocoder_Address and Geocoder_Geofield are subsequently enabled, regardless of provider, Geocoder partially forgets that the provider plugin exists. Disabling either Geocoder_Address or Geocoder_Geofield recovers the plugin discovery process.

msypes’s picture

For further information, this is what I've found in my debugging efforts when trying to edit the "GoogleMaps" provider on the configuration page:

  1. GeocoderProvider.php::line 13 gets "googlemaps" as the plugin, along with the expected configuration array
  2. The information is passed through to DefaultSingleLazyPluginCollection and its parent class, LazyPluginCollection, and an instance is created, with "googlemaps" as the sole entry in the InstanceIds array. The configuration is added subsequently.
  3. DefaultSingleLazyPluginCollection (line 83) now tries to grab the plugin "googlemaps" from the pluginInstances array, which is empty at this point.
  4. LazyPluginCollection now tries to initialize the plugin (line 80), taking us to the PluginManagerBase, and its containerFactorywhere it tries to createInstance()
  5. We now hit DiscoveryCachedTrait::getDefinitions() and DefaultPluginManager::getDefinitions(), which looks for cached definitions. What comes back is the default list of plugins — random, file, kmlfile, geojsonfile, gpxfile — which doesn't include the provider plugin "googlemaps."

I don't know exactly how the system should work, but it seems to me that either Geocoder isn't properly caching "googlemaps" (or whatever other provider has been required by composer and installed) or it shouldn't be looking strictly for cached definitions, but for all available definitions. My gut tells me it's the former.

itamair’s picture

Thanks for you efforts, and investigations.
But, personally in this cases, I really ask myself what I am doing wrong ... when I hit so fundamentals issues, that nobody else seems reporting, besides me.
Did you find any similar issue or report to your one?
Because the Geocoder 3.x branch shows almost 6k official adoptions, and it is quite a lot ... Don’t you think is weird that nobody else is reporting a so basic first installation and use issue???
I really suggest to keep debugging, with the first intent to find what is not working for you.
And I am quite confident that you will end up solving this, by yourself, without any fix to the actual module.
But also I am opening credit to this issue of you and changing it from bug to support issue and reopening as active ...
Let’s see if somebody else steps in here and subscribe & report your same issue (that hence could point to something more general and objective).

itamair’s picture

Category: Bug report » Support request
Status: Closed (cannot reproduce) » Postponed (maintainer needs more info)
itamair’s picture

Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
StatusFileSize
new265.02 KB

I further check this issue (not issue ... ),
by exactly replicating once again a clean Geocoder 3.x requirement and activation, only with the geocoder-php/free-geoip-provider requirement.

My actual setup:
PHP 7.3
Composer version 1.9.3
Drupal 9.03
Drush 10.3.4

Note: Drupal 9 should have been firstly required and installed through/with Composer (of course!)

Note2: Remove any previous Geocoder presence (may be 2.x version) with the following 2 commands:

composer remove drupal/geocoder
composer remove willdurand/geocoder
(the last one shouldn't be needed as already comprised in the first one, but just to make 100% sure ... )

These following are the command I run (relevant to this issue) to require and install all the Geocoder 3.x module & submodules with just the geocoder-php/free-geoip-provider (besides the ones already embedded in the module):

composer require drupal/address
composer require drupal/geocoder
composer require geocoder-php/free-geoip-provider
drush en address geocoder geocoder_field geocoder_geofield geocoder_address -y

... and all goes well, super charm, and I end up with a Geocoder module enabled and the capability to select and generate a free-geoip-provider (@see screenshot).

I am closing this again as I really cannot reproduce your issues, after all the time I already spent on this.

Reopen, or rather open a new more aware and focused issue if you find out that different (and specific) PHP or Composer version could be the cause of a clear issue of you, and properly document it.

We should report issues here but (very) hopefully also evidences and info on how to solve them ...

itamair’s picture

msypes’s picture

Thank you for your time.

(I have been asking myself what I'm doing wrong, but keep coming up empty, as all I'm doing is following the provided directions in the README. That's why I came here. In the hopes that someone else might notice what I'm doing wrong.)

The only differences I see in my set up are php 7.4, composer 1.10, drush 10.4, and Drupal 9.1.4

If/When I find what has caused this issue for me, I will report it.

itamair’s picture

@mspyes probably this patch: https://www.drupal.org/project/geocoder/issues/3206916#comment-14049804
and new 8.x-3.19 release is gonna solve your issues ...

msypes’s picture

Yes, updating to 3.19 did correct the issue (not issue ... ).
Thanks again.