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

craftgetIsPost() stalls any console-based migrations affecting single entries #21

Closed lmaucoin closed 4 years ago

lmaucoin commented 4 years ago

Hi! Maybe this is an unconventional approach to populating content, but I have been running a few migrations to update a ton of content between installations of my main site.

Any time I attempt to save an element, I get the following error related to a non-existent function on craft\console\Request:

Exception: Calling unknown method: craft\console\Request::getIsPost() ([...]/vendor/yiisoft/yii2/base/Component.php:300)
#0 [...]/vendor/studioespresso/craft-easyaddressfield/src/services/FieldService.php(79): yii\base\Component->__call('getIsPost', Array)
#1 [...]/vendor/studioespresso/craft-easyaddressfield/src/fields/EasyAddressFieldField.php(122): studioespresso\easyaddressfield\services\FieldServi
ce->getField(Object(studioespresso\easyaddressfield\fields\EasyAddressFieldField), Object(Solspace\Calendar\Elements\Event), NULL)
#2 [...]/calendar.ochsner.org/vendor/craftcms/cms/src/base/Element.php(2203): studioespresso\easyaddressfield\fields\EasyAddressFieldField->normalizeValue(NULL, Object(S
olspace\Calendar\Elements\Event))
[...]

In the most recent version of the plugin, it's in this line: if (Craft::$app->request->getIsPost() && $value) {

I've been able to run my migrations by changing this line to just if ($value) { ... } but I wanted it to be brought to your attention. Take care!

janhenckens commented 4 years ago

Thanks for letting me know! You'd want the geolocation function to run during the migration right?

lmaucoin commented 4 years ago

Hi @janhenckens, thanks for the quick feedback! My specific case involves adding new values to attributes to existing elements while preserving existing values for other attributes (such as the values stored by Easy Address Field) on those elements. I could imagine newly-created address values or newly-created elements would need it!

janhenckens commented 4 years ago

Gotcha! I’ll have a fix out shortly 🙂