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

Add null check for getSearchKeywords method on the AddressField #108

Closed
myleshyson opened this issue Mar 27, 2024 · 4 comments
Closed

Add null check for getSearchKeywords method on the AddressField #108

myleshyson opened this issue Mar 27, 2024 · 4 comments
Labels
Bug Report Something isn't working

Comments

@myleshyson
Copy link

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
Copy link
Author

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
Copy link
Collaborator

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

@lindseydiloreto lindseydiloreto added the Bug Report Something isn't working label Mar 27, 2024
@myleshyson
Copy link
Author

No problem!

Craft 4.7.3
Google Maps 4.3.11

@lindseydiloreto
Copy link
Collaborator

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

See the docs regarding the new event to define keywords.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants