Improve node_autocomplete_validate()
code to be less confusing
#6762
Labels
node_autocomplete_validate()
code to be less confusing
#6762
Description of the need
Some of the code in
node_autocomplete_validate()
is confusing and, if people are reading it to understand how something works, can give them the wrong idea.The code in question is:
if ($result > 0) {
seems to imply that$result
can be 1, 2, 3, etc. Whereas the PHP manual says:This is also reinforced by
$nid = $matches[$result];
where it seems that whatever the$result
value is, that's what you need to use as the key to get the value of the match. However the PHP manual says:So you may not always want the first parenthesized match, but that's all you'll ever get if you use
$result
as the key.Proposed solution
Here's what I propose changing it to:
The text was updated successfully, but these errors were encountered: