Skip to content

Skip test when opcache.enable_cli is enabled#1985

Open
GromNaN wants to merge 1 commit intomongodb:v2.xfrom
GromNaN:phpc-1839-opcache-skipif
Open

Skip test when opcache.enable_cli is enabled#1985
GromNaN wants to merge 1 commit intomongodb:v2.xfrom
GromNaN:phpc-1839-opcache-skipif

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Apr 13, 2026

When opcache.enable_cli=1, OPcache constant-folds chr(ord('a')).'rray' into the string literal "array", which PHP then interns. This causes bug1839-005.phpt to fail locally even though the driver behavior is correct.

Add a skip_if_opcache_enabled_cli() helper to tests/utils/skipif.php and use it in the test.

OPcache constant-folds chr(ord('a')).'rray' into the literal "array",
which PHP then interns. This causes the test to fail locally when
opcache.enable_cli=1, even though the driver behavior is correct.
@GromNaN GromNaN requested a review from a team as a code owner April 13, 2026 17:15
@GromNaN GromNaN requested review from alcaeus and Copilot and removed request for a team April 13, 2026 17:15
@GromNaN GromNaN changed the title PHPC-1839: Skip test when opcache.enable_cli is enabled Skip test when opcache.enable_cli is enabled Apr 13, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the PHPT test suite to avoid a known failure mode when OPcache is enabled for CLI, which can change string interning behavior and invalidate the assumptions of an existing BSON test.

Changes:

  • Add a skip_if_opcache_enabled_cli() helper to centralize OPcache CLI skip logic.
  • Update bug1839-005.phpt to skip when opcache.enable_cli=1.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/utils/skipif.php Adds a reusable skip helper for OPcache CLI affecting string interning/constant folding assumptions.
tests/bson/bug1839-005.phpt Uses the new skip helper via basic-skipif.inc to prevent false failures when OPcache CLI is enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

function createTypemap()
{
// Assemble the string so as to not have an interned string
$rootValue = chr(ord('a')) . 'rray';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chr and ord are optimized functions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants