bool PhpBridge::isScriptRestricedByOpcacheAPI()

in prod/native/libphpbridge/code/OpCache.cpp [54:72]


bool PhpBridge::isScriptRestricedByOpcacheAPI() const {
    if (!isOpcacheEnabled()) {
        return false;
    }

    char *restrict_api = INI_STR("opcache.restrict_api");
    if (!restrict_api || strlen(restrict_api) == 0) {
        return false;
    }

    size_t len = strlen(restrict_api);
    if (!SG(request_info).path_translated ||
        strlen(SG(request_info).path_translated) < len ||
        memcmp(SG(request_info).path_translated, restrict_api, len) != 0) {
        ELOGF_WARNING(log_, REQUEST, "Script '%s' is restricted by \"opcache.restrict_api\" configuration directive. Can't perform any opcache API calls.", SG(request_info).path_translated);
        return true;
    }
    return false;
}