I am getting these three notices in watchdog:

Notice: Undefined property: stdClass::$module in captcha_get_form_id_setting() (line 85 of /sites/all/modules/captcha/captcha.inc).

Notice: Undefined property: stdClass::$captcha_type in captcha_get_form_id_setting() (line 75 of /sites/all/modules/captcha/captcha.inc).

Notice: Undefined property: stdClass::$captcha_type in captcha_get_form_id_setting() (line 85 of /sites/all/modules/captcha/captcha.inc).

Patch incoming...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Michelle’s picture

Issue summary: View changes
Michelle’s picture

Status: Active » Needs review
FileSize
952 bytes

Here is the patch.

naveenvalecha’s picture

The patch is quick fix to the problem but it would be nice if you will share the whole usecase as well, So that we can get to know from where the captcha type is not set and instead fix there to find to root cause

Michelle’s picture

My assignment was to fix all the errors that turned up when the site was run on PHP 5.5 since Acquia is discontinuing 5.3 support. So all I know is these errors turned up when I spidered the site under PHP 5.5. I'm assuming it was always not set and PHP just didn't complain about it before. I don't know if I can get any time approved to dig into this error further but I can ask tomorrow.

naveenvalecha’s picture

Ok fine Thanks for the patch!
leaving the decisions for the module maintainers.

DamienMcKenna’s picture

Issue tags: +PHP 5.4
wundo’s picture

Michelle, why isset() and not empty()? :)

Michelle’s picture

The original code was checking to see if it was null. From my understanding, the equivalent of == NULL would be !isset() rather than !empty() so that's what I went with. I don't know if it really matters in this case. I was just trying to avoid changing the intent and possibly introducing other problems with my fix.

PS: I did get permission to dig into the issue further so will be doing that.

Michelle’s picture

I made some progress into figuring this out but haven't quite unravelled it. Putting what I have so far out here in case it rings a bell for someone.

  • captcha_get_form_id_setting will either use ctools (if installed) or a query to fetch the captcha points.
  • If ctools is used, at some point in ctools_export_load_object the return type ends up with "type" instead of "captcha_type" and "module" disappears.
  • If the query is used, the $captcha_point object will have "module" and "captcha_type"

So this problem only happens if cTools is installed but I'm not sure why. I was tracing through the ctools_export_load_object code but got lost in a loop. I know it starts out with both "captcha_type" and "module" from the query but that's getting messed up somewhere during the data manipulation. I still have 30 minute left to dig into this so will work on it a bit more in the morning.

Michelle’s picture

FileSize
13.54 KB

I've been digging into this more but I just don't know enough of the big picture to see how this should be working. From what I can tell, what CTools returns is totally different from what you get if you don't have CTools and just use the query because it's not returning the data it is fetching from the table.

These are the lines that determine what is being returned:

  if ($type == 'names') {
    foreach ($args as $name) {
      if (isset($cache[$table][$name])) {
        $return[$name] = $cache[$table][$name];
      }
    }
  }

That is setting $return to the what is in the attached screenshot, which isn't the data that the captcha_get_form_id_setting() function is expecting.

At this point, I don't know if the problem is 1) something wrong on this site 2) something that changed in ctools 3) captcha using ctools' function wrong 4) something else entirely. If anyone has a clue, that would be much appreciated. :)

At any rate, the patch on this issue does prevent the notices from trying to use the non-existent properties so that at least could go in.

wundo’s picture

wundo’s picture

wundo’s picture

Updating patch to use empty and adding another similar situation as well

wundo’s picture

Status: Needs review » Needs work

The last submitted patch, 13: captcha-fix-notices-2522040-13.patch, failed testing.

wundo’s picture

Status: Needs work » Needs review
FileSize
1.52 KB

Status: Needs review » Needs work

The last submitted patch, 16: captcha-fixnotices-2522040-16.patch, failed testing.

wundo’s picture

Status: Needs work » Needs review
FileSize
1.64 KB

Status: Needs review » Needs work

The last submitted patch, 18: captcha-fixnotices-2522040-18.patch, failed testing.

wundo’s picture

Status: Needs work » Fixed

  • wundo committed e11efbe on 7.x-1.x
    Issue #2522040 by wundo, Michelle, naveenvalecha: Fix undefined property...
wundo’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev

Status: Fixed » Needs review

Status: Needs review » Needs work

The last submitted patch, 18: captcha-fixnotices-2522040-18.patch, failed testing.

wundo’s picture

Status: Needs work » Patch (to be ported)
wundo’s picture

Status: Patch (to be ported) » Fixed

  • wundo committed 3f88593 on 6.x-2.x
    Issue #2522040 by wundo, Michelle: Backporting changes from Drupal 7
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.