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

CRM-20381 - ensure option to NOT geocode on imports is respected. #10181

Merged
merged 5 commits into from
Jun 4, 2017

Conversation

jmcclelland
Copy link
Contributor

@jmcclelland jmcclelland commented Apr 18, 2017

A somewhat terrifying change - we'll see how the tests do...


@eileenmcnaughton
Copy link
Contributor

@totten one for you

@jmcclelland
Copy link
Contributor Author

@totten - hey tim - just one more ping to get your opinion on this pull request.

@totten
Copy link
Member

totten commented Jun 2, 2017

jenkins, test this please


// If foreign name is set, use that name (except with callback types because
// their second parameter is the object, not the foreign name).
$name = isset($this->map[$k][1]) && $type != 'callback' ? $this->map[$k][1] : $k;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the nudge, @jmcclelland. This makes sense.

@@ -222,7 +222,7 @@ public function __get($k) {
if (!isset($this->map[$k])) {
throw new \CRM_Core_Exception("Cannot read unrecognized property CRM_Core_Config::\${$k}.");
}
if (isset($this->cache[$k])) {
if (array_key_exists($k, $this->cache)) {
Copy link
Member

@totten totten Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main question would be: do we have situations where $this->cache[$k] uses a NULL to mean "temporary cache miss"? This is hard to determine. (Just as hard as determining whether any keys have semantically meaningful NULL values.)

Re-reading the code for __get(), one branch pops out:

      case 'boot-svc':
        $this->cache[$k] = \Civi\Core\Container::getBootService($name);
        return $this->cache[$k];

The getBootService($name) could theoretically return a temporary NULL if it was called during the middle of bootstrap. OTOH, doing so would probably produce warnings. And the boot-services are really central -- I'd expect it fail prominently if this change were problematic. The fact that tests are passing is a good sign.

Still, the conservative in me would prefer one of these changes:

  • Include a unit-test for setting/getting geocodeMethod. (If there is a regression where some other thing expects NULL, the test would ensure that geocodeMethod works as expected.)
  • Keep the old handling of isset($this->cache[$k]). Instead, find the code which says $config->geocodeMethod = NULL. Change it to use empty-string (''). (If you read CRM_Utils_Geocode::getProviderClass(), it seems to be saying that the correct form of emptiness is ''.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @totten . I guess I never quite realized that isset returns true with an empty string and with FALSE, yet it returns false with NULL. I'll give it a shot. I did a quick scan and found that there are several tests in the code that use if (!empty($config->geocodeMethod)) which should work just as well with NULL or '' - but nothing that seems to expect NULL.

@totten
Copy link
Member

totten commented Jun 4, 2017

Nice updates! Thank you, @jmcclelland .

@totten totten merged commit 6038bae into civicrm:master Jun 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants