Skip to content

Fatal error when phpinfo is disabled #88

@maxmilash

Description

@maxmilash

If you put the phpinfo function in disabled_functions and try to use class Process with php8.0, it will throw the next error

PHP Fatal error: Uncaught Error: Call to undefined function phpinfo() in .../vendor/react/child-process/src/Process.php:373

There is the next code where it throw error attempting to call phpinfo function https://github.com/reactphp/child-process/blob/master/src/Process.php#L435

    /**
     * Return whether PHP has been compiled with the '--enable-sigchild' option.
     *
     * @see \Symfony\Component\Process\Process::isSigchildEnabled()
     * @return bool
     */
    public static final function isSigchildEnabled()
    {
        if (null !== self::$sigchild) {
            return self::$sigchild;
        }
        \ob_start();
        \phpinfo(\INFO_GENERAL);
        return self::$sigchild = \false !== \strpos(\ob_get_clean(), '--enable-sigchild');
    }

In the comments to the method there is a reference to a similar method from the Symfony class, where the disabled phpinfo state is provided https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Process/Process.php#L1377

    protected function isSigchildEnabled()
    {
        if (null !== self::$sigchild) {
            return self::$sigchild;
        }

        if (!\function_exists('phpinfo')) {
            return self::$sigchild = false;
        }

        ob_start();
        phpinfo(\INFO_GENERAL);

        return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
    }

Since phpinfo is disabled for security purposes in my case, is it possible to add this behavior?
Ready to send a Pull Request

Thank you for your time, checking this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions