View Issue Details

This issue affects 1 person(s).
 0
IDProjectCategoryView StatusLast Update
20867Bug reportsExpression Managerpublic2026-11-19 03:53
Reportermacwinnie Assigned To 
PrioritynoneSeveritycrash 
Status newResolutionopen 
Product Version7.11.x 
Summary20867: PHP 8.5 deprecation: preg_match() receives null during validation of an irrelevant question group
Description

When navigating through a survey, ExpressionScript may call exprmgr_regexMatch() with a null input value, triggering a PHP deprecation warning:

preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated

The error occurs in:

application/helpers/expressions/em_core_helper.php:3446

The relevant code is:

function exprmgr_regexMatch($pattern, $input)
{
    if (@preg_match($pattern . 'u', '') === false) {
        return false;
    }

    return preg_match($pattern . 'u', $input);
}

The function does not handle null input before passing it to preg_match().

One reproducible scenario involves a question group that becomes irrelevant based on an answer in a preceding group. The irrelevant group contains a mandatory question with a regular-expression validation rule.

Steps To Reproduce

Steps To Reproduce

  1. Create a survey with two question groups, Group A and Group B.

  2. In Group A, create a mandatory single-choice question:

    • Question code: choice
    • Answer codes: SKIP and SHOW
  3. Set the relevance equation of Group B to:

    choice.NAOK == 'SHOW'
  4. In Group B, create a mandatory short-text question:

    • Question code: input
    • Question validation equation:
    regexMatch('/^[A-Za-z]+$/', input)
  5. Activate or preview the survey with PHP deprecation warnings enabled.

  6. Select SKIP in Group A and click Next.

Actual Result

The survey navigation triggers a PHP deprecation warning:

preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated

application/helpers/expressions/em_core_helper.php(3446)

The stack trace includes:

exprmgr_regexMatch(..., null)
ExpressionManager->RDP_RunFunction(...)
LimeExpressionManager->_ValidateQuestion(...)
LimeExpressionManager->_ValidateGroup(...)
LimeExpressionManager::NavigateForwards()

Expected Result

Irrelevant question groups should be skipped without PHP warnings.

Regardless of whether validation expressions are evaluated for irrelevant questions, exprmgr_regexMatch() should handle null input safely.

Suggested Fix

Add an explicit null check before calling preg_match():

function exprmgr_regexMatch($pattern, $input)
{
    if ($input === null) {
        return false;
    }

    if (@preg_match($pattern . 'u', '') === false) {
        return false;
    }

    return preg_match($pattern . 'u', $input);
}

This prevents the deprecation warning without changing the behavior for non-null inputs.

Additional Information

The issue was observed while skipping an irrelevant group containing mandatory questions with validation expressions.

The underlying problem is not specific to the regular expression or question names. Any call to exprmgr_regexMatch() with a null input can trigger this deprecation warning.

TagsNo tags attached.
Bug heat0
Complete LimeSurvey version number (& build)7.11.0+261116
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMariaDB 13.0.2
Server OS (if known)
Webserver software & version (if known)
PHP Version8.5.12
Git branch / Pull Request URL

Users monitoring this issue

There are no users monitoring this issue.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2026-11-19 03:53 macwinnie New Issue