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

Fix bad exit status 255 generated by uncaught TypeError #352

Merged
merged 1 commit into from
Mar 1, 2019

Conversation

Gasol
Copy link
Contributor

@Gasol Gasol commented Feb 27, 2019

The error_get_last function returns NULL if there hasn't been an error yet, And the exit status 255 is reserved by PHP and shall be used when fatal
error occurred.

$ php -v
PHP 7.2.15-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb  8 2019 15:37:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.15-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
PHP Fatal error:  Uncaught TypeError: Return value of TheSeer\phpDox\ErrorHandler::getLastError() must be of the type array,
null returned in /net/enterprise-data1/home/ad min/gasolwu/Code/phpdox/src/shared/ErrorHandler.php:147
Stack trace:
#0 /net/enterprise-data1/home/admin/gasolwu/Code/phpdox/src/shared/ErrorHandler.php(55): TheSeer\phpDox\ErrorHandler->getLastError()
#1 [internal function]: TheSeer\phpDox\ErrorHandler->handleShutdown()
#2 {main}
  thrown in /net/enterprise-data1/home/admin/gasolwu/Code/phpdox/src/shared/ErrorHandler.php on line 147

@theseer
Copy link
Owner

theseer commented Feb 27, 2019

Nice catch. I'm wondering though if the else if is required, given both branches return the same empty array.

The problem seems to have been that I did an && check originally.
It probably should be if ($error === null || $error['....) {.

Or not?

The error_get_last function returns NULL if there hasn't been an error
yet, And the exit status 255 is reserved by PHP and shall be used when fatal
error occurred.

    PHP Fatal error:  Uncaught TypeError: Return value of TheSeer\phpDox\ErrorHandler::getLastError() must be of the type array,
    null returned in /net/enterprise-data1/home/ad min/gasolwu/Code/phpdox/src/shared/ErrorHandler.php:147
    Stack trace:
    #0 /net/enterprise-data1/home/admin/gasolwu/Code/phpdox/src/shared/ErrorHandler.php(55): TheSeer\phpDox\ErrorHandler->getLastError()
    theseer#1 [internal function]: TheSeer\phpDox\ErrorHandler->handleShutdown()
    theseer#2 {main}
      thrown in /net/enterprise-data1/home/admin/gasolwu/Code/phpdox/src/shared/ErrorHandler.php on line 147

References:
- https://secure.php.net/exit
- https://secure.php.net/error_get_last
@Gasol Gasol force-pushed the bad-exit-status-255 branch from 678b914 to 889e965 Compare February 27, 2019 16:39
@Gasol
Copy link
Contributor Author

Gasol commented Feb 27, 2019

Nice catch. I'm wondering though if the else if is required, given both branches return the same empty array.

The problem seems to have been that I did an && check originally.
It probably should be if ($error === null || $error['....) {.

Or not?

Updated, But the job is failed on Travis CI, Maybe failed on master too.

[ERROR]    PublicKey 4AA394086372C20A not found on key servers 
The command "phive --no-progress install --trust-gpg-keys 4AA394086372C20A,2A8299CE842DD38C,E82B2FB314E9906E" failed and exited with 4 during .

@theseer theseer merged commit 9ddfc98 into theseer:master Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants