Hi, everybody.

I've just come across a minor bug that occurs within the Webform Service module, but it may be caused by another module (perhaps Drupalgap, or Drupalgap Webform, or another one). I will try to describe the bug the best I can.

I have a web site which has a webform with 3 fields the users can enter data into:

  • A text field
  • An e-mail field
  • A select options field

Everything works fine here. Then I had to build a mobile app based on that web site. To achieve this, I installed the Drupalgap module, read its documentation and tried to follow its guidelines the best I can.

The app has also to offer its users the same webform described above. According to the Drupalgap module's documentation, in order to achieve this I had to install and enable a handful of modules, such as:

  • Drupalgap Webform
  • Universally Unique ID
  • Webform Service
  • Webform Submission UUID
  • webform (a Drupalgap's JavaScript module)

After all that, the webform seems to work in the app almost the same way as in the web site (there are some minor annoyances, but I think this is normal). The strangest behavior is as follows.

Every time the webform is rendered by the app, the web site's watchdog system logs 23 PHP notices, which in turn occur within less than one second. As far as I can figure out, all the PHP notices are equal:

Location: http://www.mywebsite.com/?q=drupalgap/webform/b9924c2b-07dd-49d1-93d8-29...
Referrer: http://www.mywebsite.com/mobile-application/
Message: Notice: Undefined offset: 4 in webform_service_get_submission() (line 283 of /home/mywebsite/public_html/sites/all/modules/webform_service/webform_service.module).

Looking to the offending code, I found where the bug arises:

    // Get the submitted values from this submission.
    $values = array();
    foreach ($components as $cid => $component) {
      $values[$cid] = array(
        'form_key' => $component['form_key'],
        'cid' => $component['cid'],
        'type' => $component['type'],
        'values' => $submission->data[$component['cid']]    // the offending line!
      );
    }

I wrote a simple correction for this bug (sorry, but I still haven't learned to write patch files... :( ) that seems to correct the issue:

    // Get the submitted values from this submission.
    $values = array();
    foreach ($components as $cid => $component) {
      $values[$cid] = array(
        'form_key' => $component['form_key'],
        'cid' => $component['cid'],
        'type' => $component['type']
      );
      if (isset($submission->data[$component['cid']])) {
        $values[$cid]['values'] = $submission->data[$component['cid']];
      }
    }

The log messages disappeared from my watchdog system, but I am not sure if my correction affects some expected behavior of the module.

So, I would like to ask if there is some kind friend out there who can try to replicate the bug, check if my patch code works fine for all expected situations, and find out the real root of this bug.

Many Thanks in advance! :)
Reis

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Reis Quarteu created an issue. See original summary.

tyler.frankenstein’s picture

Status: Active » Needs review
FileSize
674 bytes

tyler.frankenstein’s picture

Status: Needs review » Fixed

Thank you for the detailed bug report. I've created a patch using your fix, and have attached it to the issue for demonstration. I've committed this fix, it'll appear in the new dev release of this module in a few minutes once it's released.

I'd recommend getting yourself a GIT account with drupal.org, and practice clone/pull/add/commit/push/diff to get acquainted with drupal.org development experience.

Reis Quarteu’s picture

Thanks for your quick answer! :)
And thanks also for your suggestion! I'm not sure if I'm ready to contribute for the development of Drupal, but I'll give it a look and a try after my summer vacations. Is this a good starting point for the whole process?

Status: Fixed » Closed (fixed)

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