Skip to content

Fix test to use non-interned string - #25370

Open
rr-it wants to merge 1 commit into
php:PHP-8.6from
rr-it:fix/testcase-non-interned-string
Open

rr-it wants to merge 1 commit into
php:PHP-8.6from
rr-it:fix/testcase-non-interned-string

Conversation

@rr-it

@rr-it rr-it commented Nov 10, 2026 •

Copy link
Copy Markdown

This changes the test-case to actually use a non-interned string.

This construct actually becomes an interned string after optimizations applied in 93fd714:

$str = str_repeat("my valid string", random_int(1, 1));

php-src/ext/standard/string.c

Lines 5641 to 5643 in 93fd714

if (mult == 1) {
RETURN_STR_COPY(input_str);
}


Further random_int(1, 1) is optimized since PHP 7:

if (min == max) {
RETURN_LONG(min);
}

Implemented with c12917a and further refactored with b14dd85 and 4d8dd8d.

@ndossche

Copy link
Copy Markdown
Member

Wrong commit pointed, str_repeat got optimized such that passing 1 returns the input string, that's the root cause not the ext/random changes.
Your alternative doesn't work because of SCCP.
Also, many tests rely on the old str_repeat+random_int trick. The simplest fix is likely to change the randomness bounds to 2,2

@rr-it

rr-it commented Nov 10, 2026 •

Copy link
Copy Markdown
Author

The simplest fix is likely to change the randomness bounds to 2,2

@ndossche That one fixes it. Do you add a new PR or shall I?


Your alternative doesn't work because of SCCP.

This alternative actually works to create non-interned strings:

$strInterned = "my valid";
$strNonInterned = $strInterned . " string";

Also see:
#25371

@rr-it
rr-it force-pushed the fix/testcase-non-interned-string branch 2 times, most recently from e468c25 to 4fedde6 Compare November 10, 2026 14:22
@ndossche

Copy link
Copy Markdown
Member

This made it into 8.6, so the target branch should be PHP-8.6. You may do the fixes in this PR.

@rr-it
rr-it force-pushed the fix/testcase-non-interned-string branch from 4fedde6 to b31b3bc Compare November 10, 2026 19:14
@rr-it
rr-it changed the base branch from master to PHP-8.6 November 10, 2026 19:15
@rr-it

rr-it commented Nov 10, 2026

Copy link
Copy Markdown
Author

Commit rebased on branch PHP-8.6 and PR changed to target branch PHP-8.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants