doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 9 forks source link

Add null check for getSearchKeywords method on the AddressField #108

Closed myleshyson closed 6 months ago

myleshyson commented 6 months ago

Can you add a null check to \doublesecretagency\googlemaps\fields\AddressField::getSearchKeywords? If that field value is null, then when trying to re-save and update search indexes, that method will throw an exception.

I think you can just add something to the top like

 public function getSearchKeywords(mixed $value, ElementInterface $element): string
{
     if (!$value) {
         return '';
     }
    //...
}
myleshyson commented 6 months ago

And better can you add back the parent call so that people can hook into EVENT_DEFINE_KEYWORDS to customize how the address field keywords are indexed.

lindseydiloreto commented 6 months ago

Copy that, thanks for reporting. Out of curiosity, which version of Craft and/or Google Maps are you running?

myleshyson commented 6 months ago

No problem!

Craft 4.7.3 Google Maps 4.3.11

lindseydiloreto commented 6 months ago

Good news! Both of these changes are now available in v4.5.1. 👍

See the docs regarding the new event to define keywords.