Hello,

Quite possible that I'm missing something, but from what I can see the logic in this function currently prevents anything from ever encrypting.

Comments

Mirabuck created an issue. See original summary.

mirabuck’s picture

StatusFileSize
new2.43 KB

Very small patch attach to address this.

manuel garcia’s picture

Thanks Andrew for the patch!

I'm not sure what version you've got? This function doesnt exist on 7.x-1.3

mirabuck’s picture

Hi Manuel. Weird. Quite possible I'm missing something but if I download 7.x-1.3 via zip or clone it via git I see this function at line 134 of webform_encrypt.module:

/**
 * Encrypt all non-encrypted data of a component.
 */
function webform_encrypt_encrypt_component_data($nid = NULL, $cid = NULL, $extra = array()) {
  $results = db_query('SELECT nid, cid, extra FROM {webform_component} where nid = :nid AND cid = :cid', array(':nid' => $nid, ':cid' => $cid))->fetchAll();
  
  foreach ($results as $row) {
    $components[$row->nid . ':' . $row->cid] = unserialize($row->extra);
  }
  $data = db_query('SELECT nid, sid, cid, data FROM {webform_submitted_data} where nid = :nid AND cid = :cid', array(':nid' => $nid, ':cid' => $cid))->fetchAll();
  foreach ($data as $row) {
    $key = $row->nid . ':' . $row->cid;
    if (isset($components[$key]['encrypt']) && !$components[$key]['encrypt']) {
      db_update('webform_submitted_data')
        ->fields(array(
          'data' => encrypt($row->data, array('base64' => TRUE)),
        ))
        ->condition('nid', $row->nid)
        ->condition('sid', $row->sid)
        ->condition('cid', $row->cid)
        ->execute();
    }
  }
}

The code I'm patching is on line 146.

manuel garcia’s picture

Version: 7.x-1.3 » 7.x-1.x-dev

Wow. I think something is really wrong with the repository....

I have now cherry-picked the commit into 7.x-1.x to mitigate the problem and get things back in order. Seems to be like the last tag 7.x-1.3 is orphan form the main branch... :facepalm:

In any case, the patch now applies cleanly so we can review it and move on.

lambic’s picture

StatusFileSize
new5.63 KB

We discovered a few other small issues with these functions so I've tidied them up a bit more in this patch.

Worth noting that the encryption/decryption processes should probably use batch api so that they don't time out on forms with large numbers of submissions, but that's probably for another ticket.

joseph.olstad’s picture

still applies cleanly.

nicrodgers’s picture

Status: Needs review » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.