function hosting_context_name($nid) {
  $node = node_load($nid);
  if (!$node) {
    drupal_set_message(t('Error: cannot load node id %nid to find its context', array('%nid' => $nid)), 'error');
  }
  return '@' . $node->hosting_name;
}

I suggest only to return a string if $node is actually found. And just 'return' on failure....
Or would that break something....

I prefer failing early instead of continuing with '@' as alias.

Opinions?

CommentFileSizeAuthor
#2 hosting-context-name1.patch681 byteschertzog
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

anarcat’s picture

Status: Active » Needs work

agreed. let's return FALSE or NULL or something.

chertzog’s picture

Status: Needs work » Needs review
FileSize
681 bytes

Attached is a patch that fixes this.

helmo’s picture

Looks good!

Do we dare to commit this before the 2.0 release? Or would that be asking for it....

anarcat’s picture

i would be ready for it, this is a major WTF.

helmo’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit bccc05b on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by helmo:
    Issue #2012508 by chertzog | helmo: Fixed hosting_context_name() returns...

  • Commit bccc05b on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by helmo:
    Issue #2012508 by chertzog | helmo: Fixed hosting_context_name() returns...