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.
Problem/Motivation
When trying to import nodes using Feeds, I get the following errors...
Notice: Undefined index: value in media_wysiwyg_filter_parse_from_fields() (line 95 of modules/media_wysiwyg/includes/media_wysiwyg.file_usage.inc).
This occurs because the module tries to access $field_item['value']
without checking that it exists / is empty first.
Proposed resolution
Before trying to preg_match_all()
the data in a field, check that it has a value, and that value is not empty. That is to say, change...
foreach ($field_items as $field_item) {
preg_match_all(MEDIA_WYSIWYG_TOKEN_REGEX, $field_item['value'], $matches);
// ...
}
... to ...
foreach ($field_items as $field_item) {
if (!empty($field_item['value']) {
preg_match_all(MEDIA_WYSIWYG_TOKEN_REGEX, $field_item['value'], $matches);
// ...
}
}
Remaining tasks
Write a patch- Review, feedback
- RTBC
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2826454-2-undefined-index-value-notice.patch | 2.43 KB | mparker17 |
|
Comments
Comment #2
mparker17Here's a patch. Feedback welcome!
Comment #3
joseph.olstadHi @mparker17
did you see if the latest dev fixed this for you ? what version were you using? 7.x-2.0-beta5 or 7.x-2.x dev? there is an issue that was recently fixed for token conflicts that changed the REGEX , touched the same lines of code...
Please let us know..
wondering if your patch will cause regression on the token conflicts issue or vice versa?
Comment #5
joseph.olstadok had a look at the patch, looks reasonable, its committed to the 7.x-2.x dev branch