Closed (fixed)
Project:
CAPTCHA After
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
19 Aug 2011 at 19:59 UTC
Updated:
23 Feb 2013 at 12:50 UTC
Jump to comment: Most recent file
Need to know how to correct this:
Notice: Undefined index: form_id in captcha_after_form_pre_render() (line 95 of /srv/Drupal/7/production/drupal-7.7/sites/all/modules/captcha_after/captcha_after.module).
Notice: Only variable references should be returned by reference in captcha_after_get_captcha_element() (line 171 of /srv/Drupal/7/production/drupal-7.7/sites/all/modules/captcha_after/captcha_after.module).
Notice: Undefined index: form_id in captcha_after_form_after_build() (line 60 of /srv/Drupal/7/production/drupal-7.7/sites/all/modules/captcha_after/captcha_after.module).
Notice: Only variable references should be returned by reference in captcha_after_get_captcha_element() (line 171 of /srv/Drupal/7/production/drupal-7.7/sites/all/modules/captcha_after/captcha_after.module).
Modules Installed:
CAPTCHA 7.x-1.x-dev (2011-May-01)
CAPTCHA After 7.x-1.0
Thanks!...
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | captcha-after-debug-2.pdf | 261.98 KB | Tezza |
| #10 | captcha_after.module.zip | 2.36 KB | pivica |
| #9 | captcha-after-debug-1.jpg | 130.38 KB | Tezza |
Comments
Comment #1
x3cion commentedAny fix?
Comment #2
carl.brown commentedI was getting the 'only variables...' error reported above on a login form block, that I was embedding into a page in my template file.
It seems that updating the following function in captcha_after.module to make sure it returns a variable gets rid of the error. However, I think this is just masking the problem. I don't understand what is going on in the module well enough to really know what I'm doing!
Comment #3
pivica commentedHi guys,
Tried today to check this bug but I was not able to reproduce it locally. I was testing with D7.8, latest captcha 7.x-1.x-dev (2011-10-12).
Can somebody create exact bug report for this - what is exact configuration that reproduce this bug?
Comment #4
pivica commentedComment #5
R2-D8 commentedI was getting 'only variables...' error messages on every form where captcha_after is activated.
I found an issue thread from another module where this was also happening:
http://drupal.org/node/1155586
The simple patch from there did it for me.
In captcha_after.module replace...
return NULL;...with...
Comment #6
pivica commentedHey R2-D8 thanks, and I fully agree with you about a fix. Problem is that other functions that are calling captcha_after_get_captcha_element() are always expecting to get result and not NULL - so lets say that returning NULL is not a valid at all currently.
Can you tell me for which captcha protected forms you get this error. If you can print_r some $form value from captcha_after_get_captcha_element() call for which you are getting error and send me in attach result from print_r that would be great.
Comment #7
Tezza commentedI'm not getting the 'Notice: Undefined index: ...' error message, but I am getting the other error for my Mailing List form:
Notice: Only variable references should be returned by reference in captcha_after_get_captcha_element() (line 171 of [my locahost install]\sites\all\modules\captcha_after\captcha_after.module).
I have Devel module loaded and Display $page array checked. If i drill down through page => what am i looking for that might be of some use to you?
CAPTCHA 7.x-1.0-beta2+4-dev (2012-May-02)
captcha_after 7.x-1.0+1-dev (2012-Feb-29)
mailing_list 7.x-1.0-beta1
Comment #8
pivica commentedHi Tezza and thx for your readiness for helping to solve this bug.
Problem is in function captcha_after_get_captcha_element() which only job is to find captcha element in form array. That function for now checks captcha element in only 3 places in form array. If it fails you will get that 'Notice: Undefined index: ...' error message.
Can you try next. Edit captcha_after.module file and in captcha_after_get_captcha_element() function add next two lines of code
So your edited function should look like this
Now with that change on pages with captcha and activated captcha_after you will see devel debug message which will print $form array. Can you then check that $form array and find where is 'captcha' element inside of it - that is an info we need for this bug.
If you have trouble finding that element just save your page with debug info and attach it here so I can take a look.
Comment #9
Tezza commentedI'm probably being over-cautious but I'm a bit hesitant about posting a page from my site while logged in as user 1. It's likely not an issue so forgive my ignorance, but could I email it to you if the attached jpg is of no value?
Comment #10
pivica commentedjpg image is fine.
Problem is that I do not see captcha element in your form array anywhere - did you check all sub-elements in that array?
Is captcha enabled for that form at all - do you see a captcha widget when you disable captcha_after module?
After that checks and if you still can not figure where possible problem might be can you replace your captcha_after.module with attached file - I've added couple of more debugging statements - when you replace file, just visit your form page, expand debug elements and attach screen-shot so I can take a look.
Comment #11
Tezza commentedApologies, my screw up. I was bypassing captcha as user 1.
I've now changed permissions and logged in as an administrator on another browser. I don't have a screen capture plugin on Chrome so i've created a PDF of the captcha array.
Hope this is better.
Comment #12
pivica commentedNope it is not your mistake, captcha_after should correctly handle that use case - when captcha is skipped. And this was the info I needed to reproduce this bug and fix it. Just pushed fix for this - please test this fix when new dev version is created or just grab latest code from git.
Comment #13
Tezza commentedI'm not yet Git-savvy so I'll wait until d.o is updated.
...
Dev of 2012-May-07 fixes my 'Notice: Only variable references...' error. Thanks pivica.
Comment #14
pivica commentedGreat and thank you Tezza for your help in resolving this bug.
Comment #15
pivica commentedThis also need to be ported to 6.x version.
Comment #16
pivica commentedFinally ported this to 6.x-1.x.