API page: https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_...

This sentence:

The return value will be NULL, regardless of whether the actual value is NULL or whether the requested key does not exist.

would normally be understood to mean that the return value will always be NULL whatever the actual value and whatever the existential state of the requested key. Re-reading it, and examining the context and the code, reveal that this is not the intended meaning.

Suggested improvement:

A return value of NULL is ambiguous, and can mean either that the requested key does not exist, or that the actual value is NULL.

Comments

pushpinderchauhan’s picture

Status: Active » Needs review
StatusFileSize
new961 bytes

Please review attached patch.

jhodgdon’s picture

Version: 7.x-dev » 8.0.x-dev
Status: Needs review » Active
Issue tags: +Needs backport to D7

Thanks, looks good to me!

However, our policy is to patch Drupal 8 first, for issues that affect both. In Drupal 8, this function is NestedArray::getValue():
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!Nest...

So can we make a Drupal 8 patch for that first? Thanks!

pushpinderchauhan’s picture

Status: Active » Needs review
StatusFileSize
new1 KB

Patch for D8.

  • jhodgdon committed f485925 on 8.0.x
    Issue #2324083 by er.pushpinderrana, martin_q: Fix up description of...
jhodgdon’s picture

Status: Needs review » Fixed

Thanks! Committed appropriate patches to 8.0.x and 7.x.

  • jhodgdon committed 8af676d on 7.x
    Issue #2324083 by er.pushpinderrana, martin_q: Fix up description of...

Status: Fixed » Closed (fixed)

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