simplemap icon indicating copy to clipboard operation
simplemap copied to clipboard

Running Feedme to populate data in simplemap throws error

Open mufi-siebird opened this issue 3 years ago • 5 comments

Description

I am using Feedme plugin to automatically pull data to entry through atlas API. I have address ready. It throws error when map try to generate lat/lng. error is: Please configure UrlManager::hostInfo correctly as you are running a console application. - UrlManager.php: 648

I debug the error and found that I am on console application when queue is running from feedme. that makes this code invalid. (ether/simplemap/src/services/GeoService.php) Line Number: 774. image

Error from queue is, it needs instance of \yii\web\Request and it gets instance of \craft\console\Request.

Steps to reproduce

  1. Install Feedme plugin.
  2. add any address JSON and pull throgh feedme. (make sure lat/lng are not set.)
  3. Run feed me to add that data to entry.

Solution

it works If I change this portion:

$data = (string) static::_client()->get($url, [
    'headers' => [
        'referer' => Craft::$app->urlManager->getHostInfo()
    ]
])->getBody();

to this:

$data = (string) static::_client()->get($url, [
    'headers' => [
        'referer' => Craft::getAlias('@web')
    ]
])->getBody();

Additional info

  • Craft version: 3.7.37
  • Maps version: 3.9.3
  • PHP version: 7.4.20
  • Database driver & version: MySQL 5.7.37
  • Feedme version: 4.4.2

mufi-siebird avatar Apr 02 '22 06:04 mufi-siebird

Does changing to: 'referer' => Craft::getAlias('@web') work for both feed-me operations and the front end or do you need to make the change just for doing the feed-me and then revert to have the front end working correctly ?

tombo118 avatar Jun 21 '22 15:06 tombo118

It works on both frontend and feed me (queues).

mufi-siebird avatar Jun 21 '22 15:06 mufi-siebird

I would do something like this:

$data = (string) static::_client()->get($url, [
    'headers' => [
        'referer' => Craft::$app->getRequest()->getIsConsoleRequest() ? Craft::getAlias('@web') : Craft::$app->urlManager->getHostInfo()
    ]
])->getBody();

mufi-siebird avatar Jun 21 '22 15:06 mufi-siebird

Thank you for the speedy reply!

tombo118 avatar Jun 21 '22 16:06 tombo118

@tombo118 Just changed above code a bit to be more accurate. Do we have any updates or ETA on when it can get sorted?

mufi-siebird avatar Sep 08 '22 05:09 mufi-siebird

@mufi-siebird I opened a PR for this issue if you could +1 it for me I'd appreciate it.

maxdmyers avatar Mar 29 '24 18:03 maxdmyers