Skip to content

opcache.restrict_api may not correctly apply through web server #1639

Open
@Rarst

Description

@Rarst

Description

I observe an issue when correct opcache.restrict_api setting isn't correctly applied when run through an Apache (2.4.52) web server.

The following code:

<?php

var_dump(
	php_sapi_name(),
	ini_get( 'opcache.restrict_api' ),
	__FILE__,
	strpos( __FILE__, ini_get( 'opcache.restrict_api' ) )
);
opcache_get_status();

Non-matching path, CLI (correct, warning)

string(3) "cli"
string(10) "C:\serverr"
string(47) "C:\server\www\dev\opcache-restrict-api-test.php"
bool(false)

Warning: Zend OPcache API is restricted by "restrict_api" configuration directive in C:\server\www\dev\opcache-restrict-api-test.php on line 9

Non-matching path, web server (correct, warning)

string(14) "apache2handler" string(10) "C:\serverr" string(47) "C:\server\www\dev\opcache-restrict-api-test.php" bool(false)
Warning: Zend OPcache API is restricted by "restrict_api" configuration directive in C:\server\www\dev\opcache-restrict-api-test.php on line 9

Matching path, CLI (correct, no warning)

string(3) "cli"
string(9) "C:\server"
string(47) "C:\server\www\dev\opcache-restrict-api-test.php"
int(0)

Matching path, web server (INCORRECT, warning)

string(14) "apache2handler" string(9) "C:\server" string(47) "C:\server\www\dev\opcache-restrict-api-test.php" int(0)
Warning: Zend OPcache API is restricted by "restrict_api" configuration directive in C:\server\www\dev\opcache-restrict-api-test.php on line 9

PHP Version

8.1.2

Operating System

Windows 10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions