Problem/Motivation

Site crashes, getting this error in the logs:

TypeError : Argument 1 passed to Drupal\geofield_map\Services\MarkerIconService::getIconFileManagedElement() must be of the type int, null given, called in /var/www/html/web/modules/contrib/geofield_map/src/Plugin/Field/FieldFormatter/GeofieldGoogleMapFormatter.php on line 342

Here is the code failing:

'icon_file' => $this->markerIcon->getIconFileManagedElement($fid),

Actually the parameter $fid is initialized to NULL if not found:

$fid = (integer) !empty($settings['map_marker_and_infowindow']['icon_file_wrapper']['icon_file']['fids']) ? $settings['map_marker_and_infowindow']['icon_file_wrapper']['icon_file']['fids'] : NULL;

Looks like some better error handling is needed here.

Steps to reproduce

Not sure how to reproduce it.

Proposed resolution

Set icon file to NULL if $fid is NULL? At least it doesn't crash anymore.

Comments

mably created an issue. See original summary.

  • itamair committed beae3ae on 8.x-2.x
    fix of 'Issue #3293108: Argument 1 passed to Drupal\geofield_map\...
itamair’s picture

Status: Active » Needs review

New 8.x-2.82 release should have fixed this ... please test and review and provide feedback here.

mably’s picture

Can confirm that the problem has been fixed with release 2.82.

Thanks for the quick fix!

itamair’s picture

Status: Needs review » Fixed

thanks for reporting this @mably, you are welcome

desierto’s picture

I presume this must be related. I upgraded to 2.84 from 2.80 and thereafter got this error (and the page failing to load) every time I visit a page with a GeoField map. I downgraded to 8.82, but the error persists... downgraded to 2.80 and it goes away.

TypeError: Argument 8 passed to Drupal\geofield_map\Services\MarkerIconService::__construct() must implement interface Drupal\Core\File\FileUrlGeneratorInterface, instance of Drupal\redirect_404\Render\Redirect404LogSuppressor given, called in /www/wildsonora/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 in Drupal\geofield_map\Services\MarkerIconService->__construct() (line 240 of /www/wildsonora/web/modules/contrib/geofield_map/src/Services/MarkerIconService.php)

itamair’s picture

@desierto it looks to me that you simply forgot to clear the drupal cache after upgrading your geofield_map module.
Don't forget to always do that.
I would bet it would solve also this issue of you ...

desierto’s picture

@itamair, thank you for the suggestion... I upgraded just now and it went straight to today's latest 2.85 release. I cleared the cache and it did fix my issue. I think many modules when updated call for an /update.php cache clear, if needed. Thanks... I appreciate the help.

Status: Fixed » Closed (fixed)

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