Problem/Motivation

On Drupal 9.1.5
In Geocoder.php public function geocode receives an array of strings instead of an array of GeocoderProviderInterface

Steps to reproduce

1. Install geocoder-php/google-maps-provider
2. Configure GeoCoder with this manual https://www.drupal.org/node/2073709
3. Search.

As a result
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getPlugin() on string in Drupal\geocoder\Geocoder->geocode() (line 63 of modules/contrib/geocoder/src/Geocoder.php).
Drupal\geocoder\Geocoder->geocode('08540', Array, Array) (Line: 78)
Drupal\search_api_location_geocoder\Plugin\search_api_location\location_input\Geocode->getParsedInput(Array) (Line: 195)
Drupal\search_api_location_views\Plugin\views\filter\SearchApiFilterLocation->query() (Line: 1373)
Drupal\views\ViewExecutable->_build('filter') (Line: 1262)
Drupal\views\ViewExecutable->build() (Line: 387)
Drupal\views\Plugin\views\display\PathPluginBase->execute() (Line: 180)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1630)
Drupal\views\ViewExecutable->executeDisplay('page', Array) (Line: 77)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 781)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 372)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 706)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Issue fork geocoder-3202941

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

EugeneChechel created an issue. See original summary.

eugenechechel’s picture

This patch fixes the issue for me

eugenechechel’s picture

itamair’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks @EugeneChechel for reporting this singular issue and your potential fix/path.

But if you want to have it merged into Geocoder 8.x-3.x branch I need to better understand your use case and how to exactly reproduce this.
I am not 100% sure that this is a Geocoder issue, and not a search_api_location module one (that may be is not matching last 3.x branch providers structures) ...

This you mention: https://www.drupal.org/node/2073709 looks super old and not really matching Drupal 8+ scenarios.
If I enable the "search_api_location" module and its search_api_location_views and search_api_location_geocoder submodules (that I am not really expert/aware of ...) I can see that my Latitude/Longitude Data Type (in my Geofield stack testing Drupal 8+ app) is not supported (@sse screenshot).

Please provide much more detailed description so I could easily recreate your exact/similar issue scenario: what you want to achieve and which are the exacts steps to enable your modules & views settings and configurations, etc.

itamair’s picture

Priority: Major » Normal

... and as this is a very singular use case, I wouldn't tag this as a Major one ...

nicrodgers’s picture

I had this after upgrading from geocoder 2 to 3. The solution is to apply this patch to search_api_location to make it compatible with geocoder 3:
https://www.drupal.org/node/3048597

aschiwi’s picture

I had this problem and was happy to find the patch in #3 solves it.
We do not use search_api_location. I can't tell you how to reproduce it, we had this problem on a fairly complex site that we did not build but recently upgraded from Drupal 8 to Drupal 9.

@itamair: If you want to at least see where exactly this happened to us, dm me. I'll send you a link.

stBorchert made their first commit to this issue’s fork.

itamair’s picture

Status: Postponed (maintainer needs more info) » Fixed
stborchert’s picture

Status: Fixed » Active

Sorry, but this is still active. Without the patch in #3 we still got this error. I don't see the changes in branch 8.x-3.x.

itamair’s picture

Patch #3 it doesn't apply cleanly to the actual 3.x-dev branch, and it is also missing the reverse method of the same Geocoder object.
This new attached patch is fixing that.
I am going to commit this into 3.x-dev branch, but this mostly looks a workaround to me.

More solid fix seems is gonna happen in the search_api_location to make it compatible with geocoder 3, as mentioned in Comment #6

itamair’s picture

itamair’s picture

  • itamair committed 92f4893 on 8.x-3.x
    Issue #3202941 by EugeneChechel, itamair, stBorchert: Plugin comes as a...
itamair’s picture

Status: Active » Fixed

Patch #11 committed into dev, and deploying a new 8.x-3.22 release with it.

Status: Fixed » Closed (fixed)

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