php / php/php-src

Preloading has no defined io-stream constants

Open
#10,673 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: opcache SAPI: cli Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

As of https://www.php.net/manual/en/features.commandline.io-streams.php , there should be constants defined in CLI.

Added the following to preload.ini:

opcache.preload_user=www-data
opcache.preload=/path/to/preload.php

The following code wrote to preload.php:

<?php

var_dump(defined('STDIN'));
var_dump(defined('STDOUT'));
var_dump(defined('STDERR'));

Resulted in this output:

/path/to/preload.php:3:
bool(false)
/path/to/preload.php:4:
bool(false)
/path/to/preload.php:5:
bool(false)

But I expected this output instead:

/path/to/preload.php:3:
bool(true)
/path/to/preload.php:4:
bool(true)
/path/to/preload.php:5:
bool(true)

I could imagine this is the expected behavior but docs should be updated then. :) There are no restrictions defined in https://www.php.net/manual/en/opcache.preloading.php BTW, the opcache_enabled shown as false for var_dump(opcache_get_status(false));.

PHP Version

8.1.16

Operating System

Docker image: php:8.1-fpm-bullseye

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report using preload.ini and preload.php in the PHP 8.1.16 php:8.1-fpm-bullseye image, then compare the result with the CLI I/O streams and opcache preloading documentation linked in the issue. Determine whether STDIN, STDOUT, and STDERR should be defined during preloading; done means either the behavior works as expected or the documentation clearly states the restriction.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.