Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error importing Simple Map: Access to undeclared static property #497

Closed
BridgingUnit opened this issue Mar 22, 2019 · 3 comments
Closed

Comments

@BridgingUnit
Copy link

BridgingUnit commented Mar 22, 2019

Hi,

I'm getting an error running an import via Feed Me into a Map field.

The Feed Me log flags up the following error, and then bails out from any import at all:

Access to undeclared static property: ether\simplemap\SimpleMap::$plugin - SimpleMap.php: 94

Thanks for any help.

Latest version of Craft (3.1.19), FeedMe (3.1.16) and Map (3.4.4)

@BridgingUnit
Copy link
Author

BridgingUnit commented Mar 23, 2019

Not sure if I've got this right, but is that error referring to line 94 here?

https://github.com/verbb/feed-me/blob/craft-3/src/fields/SimpleMap.php

i.e. to

$apiKey = SimpleMapPlugin::$plugin->getSettings()->unrestrictedApiKey;

within _getAddressFromLatLng($lat, $lng)

If yes, then another problem is that latest version of Simple Map has changed its settings and no longer has a setting by that key. Think it needs instead to be geoToken, falling back to mapToken.

My feed was pulling in lat, long, and zoom, but not address (the EE version being pulled in from doesn't have one to pull in). So I'm guessing the code is trying to figure that out for me because it was absent.

But, I might be misunderstanding....

A further thing though:

In Feed Me I tried setting the field to 'Don't import', so that I could carry on populating these entries and come back later to update the Map field as a second pass, but I still hit a wall. This time with a different error:

array_merge(): Argument #2 is not an array - MapService.php: 325

This looks to be a problem in Simple Map. It's getting triggered for the same reason - trying to populate address based on lat/lng because address not supplied. But the error here - I think - is that it's trying to array_merge in an object returned from Simple Map's GeoService.php after a successful query to Google.

Have reported that back to Etheya here:
ethercreative/simplemap#138

But it raises another potential issue in Feed Me:

If I set a field to 'Don't import', then I'd expect it to not try. At all. And, if it didn't, I'd not be hitting this secondary error and could proceed to populate my entries, ignoring the map field entirely.

Thoughts?

@BridgingUnit
Copy link
Author

BridgingUnit commented Mar 23, 2019

So, in here:

https://github.com/verbb/feed-me/blob/craft-3/src/fields/SimpleMap.php

I think you want lines 94-97 as follows:

        $apiKey = SimpleMapPlugin::getInstance()->getSettings()->geoToken;

        if (!$apiKey)
            $apiKey = SimpleMapPlugin::getInstance()->getSettings()->mapToken;

Instead of

        $apiKey = SimpleMapPlugin::$plugin->getSettings()->unrestrictedApiKey;

        if (!$apiKey)
            $apiKey = SimpleMapPlugin::$plugin->getSettings()->apiKey;

That appears to fix both the issue with deprecated settings keys, but also the undeclared static property issue.

Please check. Hopefully I'm on the right track. Look forward to your input.

@engram-design
Copy link
Contributor

Fixed in 3.1.17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants