Skip to content

Language: var_export(require_once) after once returns int not true (re-#21938, Zend/zend_execute.c) #25852

Description

@PurHur

Category

bug · php-src-strict · language · require_once / include_once already-loaded return

Problem

After a file has been require_once/include_once’d, Zend returns boolean true for a subsequent once-include. Passing that expression directly into var_export(...) (or similar) under the VM yields a pid-like int instead of true. Storing the second once-include in a temporary first matches Zend.

Distinct from bare require_once as a statement / $x = require_once (those already match). Sibling of #25851 (var_export(include, true) two-arg remap).

Probed 2026-07-31 @ 3aa069e85 — Zend 8.2.32 vs php bin/vm.php.

Repro Zend 8.2.32 VM (2026-07-31)
require_once $path; var_export(require_once $path); (return 42 file) true pid-like int
$a=require_once $path; $b=require_once $path; var_export($b) true true
First require_once expression value 42 42

php-src reference

PHP implementation target

  • Ensure already-loaded *_once produces a real boolean true temp when used as a call argument (not a stolen prior getmypid/path temp)
  • lib/ compile + VM include path; PHP-in-PHP only

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/ve_require_once.php <<'"'"'PHP'"'"'
<?php
$path = sys_get_temp_dir() . "/ro_" . getmypid() . ".php";
file_put_contents($path, "<?php return 42;\n");
require_once $path;
echo var_export(require_once $path, true), "\n";
$a = require_once $path;
$b = require_once $path;
echo var_export($a, true), "|", var_export($b, true), "\n";
@unlink($path);
PHP
php /tmp/ve_require_once.php
php bin/vm.php /tmp/ve_require_once.php'

Done when

  • var_export(require_once \$path) / var_export(include_once \$path) after first load prints true
  • Assignment form still green; first-load return value unchanged
  • Compliance .phpt under test/compliance/cases/language/
  • php-src-strict; no php-compiler-strict shortcut

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions