Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#2 | hosting-context-name1.patch | 681 bytes | chertzog |
Comments
Comment #1
anarcat CreditAttribution: anarcat commentedagreed. let's return FALSE or NULL or something.
Comment #2
chertzogAttached is a patch that fixes this.
Comment #3
helmo CreditAttribution: helmo commentedLooks good!
Do we dare to commit this before the 2.0 release? Or would that be asking for it....
Comment #4
anarcat CreditAttribution: anarcat commentedi would be ready for it, this is a major WTF.
Comment #5
helmo CreditAttribution: helmo commentedcommitted