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.
The issue
No cookie duration was set when creating the poll, as it wasn't a required field. The installation is different too, as we're using Drupal Commerce: http://www.drupalcommerce.org/
The error messages
Notice: Undefined index: und in advpoll_get_data() (line 60 of /var/www/tradies/dev/sites/all/modules/advpoll/includes/advpoll_helper.inc).
Notice: Undefined index: und in advpoll_get_data() (line 60 of /var/www/tradies/dev/sites/all/modules/advpoll/includes/advpoll_helper.inc).
Notice: Undefined index: und in advpoll_get_data() (line 60 of /var/www/tradies/dev/sites/all/modules/advpoll/includes/advpoll_helper.inc).
Notice: Undefined index: und in advpoll_get_data() (line 60 of /var/www/tradies/dev/sites/all/modules/advpoll/includes/advpoll_helper.inc).
Notice: Undefined index: und in advpoll_get_data() (line 60 of /var/www/tradies/dev/sites/all/modules/advpoll/includes/advpoll_helper.inc).
Notice: Undefined index: und in advpoll_get_data() (line 60 of /var/www/tradies/dev/sites/all/modules/advpoll/includes/advpoll_helper.inc).
I tracked down the problem by using dpm() and this particular field was the culprit:
advpoll_helper.inc
dpm($node->advpoll_cookie_duration);
advpoll_helper.inc
(isset($node->advpoll_cookie_duration[$lang])) ? $data['cookie_duration'] = $node->advpoll_cookie_duration[$lang][0]['value'] : $data['cookie_duration'] = $node->advpoll_cookie_duration['und'][0]['value'];
Our fix
advpoll_helper.inc
(isset($node->advpoll_cookie_duration[$lang])) ? $data['cookie_duration'] = $node->advpoll_cookie_duration[$lang][0]['value'] : $data['cookie_duration'] =
(isset($node->advpoll_cookie_duration[LANGUAGE_NONE][0]['value']) ? $node->advpoll_cookie_duration['und'][0]['value'] : 0);
As I'm still new to PHP, I'm not sure if this is the best fix. There may be a more elegant solution, but this worked for us.
Comment | File | Size | Author |
---|---|---|---|
#2 | advpoll-undefined-cookie-duration-2124519-2.patch | 1.48 KB | jacob.embree |
Screen Shot 2013-10-31 at 12.12.24 PM.png | 41.49 KB | NavySeal | |
Screen Shot 2013-10-31 at 12.03.38 PM.png | 62.82 KB | NavySeal |
Comments
Comment #1
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedCan a patch be made to apply and test?
Comment #2
jacob.embree CreditAttribution: jacob.embree commentedHopefully this has the desired effect. It's a lot more readable, anyway. I have not tested this.
Comment #3
tripper54 CreditAttribution: tripper54 commentedGreat patch, thanks. Committed!