In line 159 of webform_validation.module you compare to WEBFORM_CONDITIONAL_INCLUDE this constant is not set in the 7.x-3.x version off webform, it appears to be added to the 7.x-4.x branch. When attempting to validate a field with regex or pattern and I suspect any validator on receives the notice:

Notice: Use of undefined constant WEBFORM_CONDITIONAL_INCLUDE - assumed 'WEBFORM_CONDITIONAL_INCLUDE' in webform_validation_validate() (line 159 of /v...

To fix this I added the following just bellow your includes:

<?php
/**
 * Add check for WEBFORM_CONDITIONAL_INCLUDE and define if needed.
 */
if (!defined('WEBFORM_CONDITIONAL_INCLUDE')) {
  define('WEBFORM_CONDITIONAL_INCLUDE', 1);
}
?>
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

undertext’s picture

Here is the patch with the same code fix.

Liam Morland’s picture

If that constant isn't there, does _webform_client_form_rule_check() still behave the same way? It looks like it returns a Boolean. That will require a more elaborate change to make it work properly.

I am inclined to drop support for Webform 3 if supporting it means significant separate code paths.

Liam Morland’s picture

Version: 7.x-1.8 » 7.x-1.x-dev
Liam Morland’s picture

Liam Morland’s picture

A potentially better approach: Check of WEBFORM_CONDITIONAL_INCLUDE exists. If it does, behave like now, otherwise, behave based on the output of _webform_client_form_rule_check() from Webform 3 (I think it is boolean).

fabiobosio’s picture

Hi to all,

I put the code in the module , "webform_validation.module", but the error still persists.

Someone can help me?

Fabio

hedroom’s picture

It seems that webform 3.x does not use these constants at all. So wouldn't be better to just define them at the top of the webform.module file like they are in 4.x?

I added:

define('WEBFORM_CONDITIONAL_EXCLUDE', 0);
define('WEBFORM_CONDITIONAL_INCLUDE', 1);
define('WEBFORM_CONDITIONAL_SAME_PAGE', 2);

at the top of webform.module and that fixed the problem for me.

Looking at the function _webform_client_form_rule_check(), it looks like this should work properly...

Wade

Liam Morland’s picture

We don't want to get rid of the error, but break validation at the same time.

In Webform 4, _webform_client_form_rule_check() returns an integer. In Webform 3, it returns a Boolean, so it will never match any of the WEBFORM_CONDITIONAL_* constants. The comparison is made with "!==", so the type needs to match too.

Maybe casting the return value of _webform_client_form_rule_check() to integer would work as part of the solution.

Liam Morland’s picture

Please try this patch.

  • Liam Morland committed 694ca89 on 7.x-1.x
    Issue #2417015: Restore compatibility with Webform 3 lost in 803d340 due...
Liam Morland’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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