Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error when phpinfo is disabled #5709

Closed
maxmilash opened this issue Oct 1, 2021 · 5 comments
Closed

Fatal error when phpinfo is disabled #5709

maxmilash opened this issue Oct 1, 2021 · 5 comments

Comments

@maxmilash
Copy link

Bug report

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

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

There is the next code where it throw error attempting to call phpinfo function

    /**
     * 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 to phpstan?
Ready to send a Pull Request

Thank you for your time, checking this issue.

Code snippet that reproduces the problem


Expected output

No fatal error

@mergeable
Copy link

mergeable bot commented Oct 1, 2021

This bug report is missing a link to reproduction on phpstan.org.

It will most likely be closed after manual review.

@staabm
Copy link
Contributor

staabm commented Oct 2, 2021

Sounds like you should report it to react/child-process

@maxmilash
Copy link
Author

Thanks. Created a report to react/child-process
I will keep you informed

@ondrejmirtes
Copy link
Member

Updated react/child-process here: phpstan/phpstan-src@ca3aad0

Feel free to test dev-master of phpstan/phpstan.

Thanks.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants