Issue #3575644: Inefficient RegexConstraint on StringLong fields causes "JIT stack limit reached"

Fixes the string_long field validation failure reported in work item 3575644.

The (.|\r?\n)* PCRE exhausts the PCRE JIT stack on long values: preg_match() returns FALSE with PREG_JIT_STACKLIMIT_ERROR, which Symfony's Regex validator reports as a failed match. Saving a string_long field with ~10k+ characters then fails with "This value is not valid."

This MR normalizes that one pattern to its DOTALL equivalent /.*/s in JsonSchemaType::patternToPcre(), the single point that builds PCRE from a JSON Schema pattern. StringLongItemOverride now calls that helper instead of hardcoding the PCRE. The field constraint and the prop requirement built in toDataTypeShapeRequirements() stay byte-identical, so EntityFieldPropSourceMatcher (which compares Regex constraints by value) keeps matching multiline-string props.

A one-line change to only StringLongItemOverride would have regressed that prop-source matching; both sides are kept in sync instead.

AI-Generated: Yes (Used Claude Code to diagnose the root cause, implement the fix across both sites, and write the test).

Testing instructions

  • Run the new unit test: composer run phpunit -- tests/src/Unit/JsonSchemaInterpreter/JsonSchemaTypeTest.php — asserts patternToPcre('(.|\r?\n)*') returns a JIT-safe PCRE that matches a 20,000-character multiline string with PREG_NO_ERROR.
  • Run the coupling tests: composer run phpunit -- tests/src/Kernel/ShapeMatcher/EntityFieldPropSourceMatcherTest.php tests/src/Kernel/PropShapeRepositoryTest.php — confirm multiline-string props still match string_long.
  • Manually: create a node type with a plain long-text field, save a node with 15,000+ characters in it. Before this change the save fails with "This value is not valid"; after, it saves.

Closes #3575644

Edited by Matt Glaman

Merge request reports

Loading