php / php/doc-en

opcache.revalidate_path and opcache.use_cwd noop?

Open
#4,583 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Extension: opcache Status: Needs Triage
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

Description

The following code:

It's unclear what exactly the difference between opcache.revalidate_path and opcache.use_cwd is and it seems they're noop (in CLI?)?
Assuming php.ini has: include_path=/dev/null

/foo/safe.php
/bar/safe.php

<?php
function run() {
    echo __FILE__;
}

/foo/x.php
/bar/y.php

<?php
include 'safe.php';

/test.php

<?php
require __DIR__ . '/foo/x.php';
require __DIR__ . '/bar/y.php';

run();

php -dopcache.enable_cli=1 -dopcache.revalidate_path=0 -dopcache.use_cwd=0 test.php

Resulted in this output:

Cannot redeclare run()

But I expected this output instead:

/foo/safe.php

Changing /foo/x.php or /bar/y.php to

<?php
opcache_compile_file('safe.php');

has the same issue too.

According to https://github.com/php/php-src/issues/17769#issuecomment-2682719493 this shouldn't result in a fatal, because the provided path is the same for both, so it shouldn't even attempt to load the other

Also it's not entirely clear what the difference between these 2 directives actually is, based on a practical example.

PHP Version

PHP 8.4

Operating System

No response

Contributor guide

No contributing guide indexed for this repository

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

Start by reviewing the PHP documentation for opcache.revalidate_path and opcache.use_cwd, then compare the reported PHP 8.4 CLI behavior and linked issue discussion. Done means the practical distinction between the directives and their behavior in this example is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.