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.
I just upgraded the module from 7.x-1.0-beta3 to 7.x-3.0 (and Media module from v1.4 to v1.5) and now when viewing a node I got about 30 undefined index errors, because media_youtube_preprocess_media_youtube_video()
assumed all the keys would be present, and most of them are not. In fact, it looks like they were all deliberately deleted in media_youtube_update_7203()
!
I was able to prevent all the undefined index errors by adding isset()
calls in the code, as in the attached patch.
Comment | File | Size | Author |
---|---|---|---|
media_youtube-prevent_undefined_indexes.patch | 3.46 KB | jenlampton | |
Comments
Comment #1
jenlamptonComment #2
jenlamptonComment #3
das-peter CreditAttribution: das-peter at Cando commentedHow about using something like:
Less code
No notices if an option is missing.
Explicit option set to 0 / 1 - defaults to 0 if an option is missing, Currently it looks like I can't disable autoplay - because if the autoplay option is set but is 0 - I still get
$query[$option] = 1;
Comment #4
das-peter CreditAttribution: das-peter at Cando commentedJust struggled with this - I guess this should be
if (!empty($variables['options']['loop'])) {
I guess these also should use
!empty()
.