Problem/Motivation
I found the following notice in some cases:
Notice: Undefined variable: prefix in entityreference_autocomplete_callback_get_matches() (line 1045 of entityreference.module
Proposed resolution
Checking the code it seems that $prefix has a chance of not being defined in the following [ from row 1037 of current dev version, entityreference.module ]:
if ($type == 'tags') {
// The user enters a comma-separated list of tags. We only autocomplete the last tag.
$tags_typed = drupal_explode_tags($string);
$tag_last = drupal_strtolower(array_pop($tags_typed));
if (!empty($tag_last)) {
$prefix = count($tags_typed) ? implode(', ', $tags_typed) . ', ' : '';
}
}
else {
// The user enters a single tag.
$prefix = '';
$tag_last = $string;
}
I simply propose to declare
$prefix = ''
at the beginning of entityreference_autocomplete_callback_get_matches function just before or after
$matches = array();
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 2202501-1-undefined-notice-prefix.patch | 691 bytes | hanoii |
Comments
Comment #1
hanoiiFollow up patch of @spesso recommendation with a slight line remove as it's not needed with the change.
Comment #2
mustanggb commentedComment #3
mustanggb commentedComment #4
mustanggb commentedWhoops!
Comment #5
othermachines commentedMarked another issue as duplicate: #2203705: Nodes that start with " are not getting listed
Comment #7
spotzero commentedCommitted.