studioespresso / craft-easyaddressfield

Easy Address Field is the easiest way to add an address to your entries. Enable the fields you want for the address, automatically get the coordinates for an address and place the marker exactly where you want it.
https://plugins.craftcms.com/easy-address-field
Other
3 stars 3 forks source link

Error when saving entry state is null when state is not enabled in field setup #26

Closed bartroelands closed 4 years ago

bartroelands commented 4 years ago

Hello,

When using the address field without the state enabled in the field definition I still get an error on missing state value when saving the entry (log below)

``2020-11-28 19:52:56 [-][1][-][error][TypeError] TypeError: Argument 1 passed to maxh\Nominatim\Search::state() must be of the type string, null given, called in /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/studioespresso/craft-easyaddressfield/src/services/GeoLocationService.php on line 45 and defined in /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/maxh/php-nominatim/src/Search.php:111 Stack trace:

0 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/studioespresso/craft-easyaddressfield/src/services/GeoLocationService.php(45): maxh\Nominatim\Search->state()

1 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/studioespresso/craft-easyaddressfield/src/services/GeoLocationService.php(32): studioespresso\easyaddressfield\services\GeoLocationService->geocodeOSM()

2 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/studioespresso/craft-easyaddressfield/src/services/FieldService.php(43): studioespresso\easyaddressfield\services\GeoLocationService->locate()

3 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/studioespresso/craft-easyaddressfield/src/fields/EasyAddressFieldField.php(208): studioespresso\easyaddressfield\services\FieldService->saveField()

4 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/base/Element.php(3196): studioespresso\easyaddressfield\fields\EasyAddressFieldField->afterElementSave()

5 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/elements/Entry.php(1501): craft\base\Element->afterSave()

6 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/services/Elements.php(2454): craft\elements\Entry->afterSave()

7 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/services/Elements.php(755): craft\services\Elements->_saveElementInternal()

8 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/controllers/EntryRevisionsController.php(269): craft\services\Elements->saveElement()

9 [internal function]: craft\controllers\EntryRevisionsController->actionSaveDraft()

10 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()

11 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/yiisoft/yii2/base/Controller.php(180):

yii\base\InlineAction->runWithParams()

12 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction()

13 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction()

14 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction()

15 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/web/Application.php(577): craft\web\Application->runAction()

16 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/craftcms/cms/src/web/Application.php(253): craft\web\Application->_processActionRequest()

17 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest()

18 /usr/share/craft/releases/30c037012503f952404028f9e85ae39b0b90e8fc/web/index.php(22): yii\base\Application->run()``

janhenckens commented 4 years ago

Hey Bart, you just beat me to it, I ran into this myself on Friday :) Fix coming up later today!

janhenckens commented 4 years ago

Fixed in today's update!