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: Uncaught Error: Call to undefined method Error::shutdown_handler() #1942

Closed
kenjis opened this issue Oct 21, 2015 · 17 comments
Closed

Comments

@kenjis
Copy link
Contributor

kenjis commented Oct 21, 2015

Is this a bug of PHP or Fuel?

Fatal error: Uncaught Error: Call to undefined method Error::shutdown_handler() in .../fuel-1.8-dev/fuel/core/bootstrap.php:71 Stack trace: #0 [internal function]: {closure}() #1 {main} thrown in .../fuel-1.8-dev/fuel/core/bootstrap.php on line 71

Fix:

--- a/bootstrap.php
+++ b/bootstrap.php
@@ -68,7 +68,7 @@ register_shutdown_function(function ()
            logger(\Fuel::L_ERROR, 'shutdown - ' . $e->getMessage()." in ".$e->getFile()." on ".$e->getLine());
        }
    }
-   return \Error::shutdown_handler();
+ return Fuel\Core\Error::shutdown_handler();
 });

 set_exception_handler(function (\Exception $e)
$ php -v
PHP 7.0.0RC5 (cli) (built: Oct 14 2015 19:49:05) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
@WanWizard
Copy link
Member

Fuel v1 hasn't been tested on PHP7 yet, so I couldn't say.
The Error class should have been aliased there.

@kenjis
Copy link
Contributor Author

kenjis commented Oct 21, 2015

Can't use Error class on PHP7. See http://php.net/manual/en/class.error.php

@WanWizard
Copy link
Member

I know (just didn't think of it).

It's something that needs to be addressed, because your fix means you can't overload the Error class anymore.

@emlynwest
Copy link
Contributor

Looks like we need to rename the Error class for PHP7

@kenjis
Copy link
Contributor Author

kenjis commented Oct 21, 2015

Yes, we need to rename the Error class.

@WanWizard
Copy link
Member

There might be other PHP7 fixes needed. Changing this will break BC for v1 (in regards to extending the Error class), so I need a careful think about how to address this issue.

We might have to use the same sort of trick we used for Redis when that became a PHP extension.

@emlynwest
Copy link
Contributor

This could simply be something we need to break to continue with php7, how many people extend the Error class anyway?

@WanWizard
Copy link
Member

Already addressed, fix is on it's way ;) I just hate breaking BC if it's not needed.

@kenjis
Copy link
Contributor Author

kenjis commented Oct 21, 2015

Thank you!

Now only one test fails:

$ fuel/vendor/bin/phpunit -v -c fuel/core/phpunit.xml 
PHPUnit 4.8.14-2-ga4513c4 by Sebastian Bergmann and contributors.

Runtime:    PHP 7.0.0RC5
Configuration:  /mnt/project/fuel-1.8-php7/fuel/core/phpunit.xml

...............................................................  63 / 389 ( 16%)
............................................................... 126 / 389 ( 32%)
......................................................F........ 189 / 389 ( 48%)
............................................................... 252 / 389 ( 64%)
............................................................... 315 / 389 ( 80%)
............................................................... 378 / 389 ( 97%)
...........

Time: 12.11 seconds, Memory: 12.00Mb

There was 1 failure:

1) Fuel\Core\Test_Format::test_to_xml_boolean with data set #0 (array(array('Value 1', 35, true, false)), '<?xml version="1.0" encoding=.../xml>\n', '<?xml version="1.0" encoding=.../xml>\n', '<?xml version="1.0" encoding=.../xml>\n')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?xml version="1.0" encoding="utf-8"?>
-<xml><item><field1>Value 1</field1><field2>35</field2><field3>1</field3><field4/></item></xml>
+<xml><item><field1>Value 1</field1><field2>35</field2><field3>1</field3><field4></field4></item></xml>
 '

/mnt/project/fuel-1.8-php7/fuel/core/tests/format.php:414

FAILURES!
Tests: 389, Assertions: 481, Failures: 1.

@WanWizard
Copy link
Member

This is not an easy fix, as xml is processed by an extension using libxml, which seems to treat false values different between 5.x <field4/> and 7.0 <field4></field4>

@kenjis
Copy link
Contributor Author

kenjis commented Oct 21, 2015

How about this?

--- a/tests/format.php
+++ b/tests/format.php
@@ -125,6 +125,9 @@ line 2","Value 3"',
 <xml><item><field1>Value 1</field1><field2>35</field2><field3>1</field3><field4/></item></xml>
 ',
                '<?xml version="1.0" encoding="utf-8"?>
+<xml><item><field1>Value 1</field1><field2>35</field2><field3>1</field3><field4></field4></item></xml>
+',
+             '<?xml version="1.0" encoding="utf-8"?>
 <xml><item><field1>Value 1</field1><field2>35</field2><field3>true</field3><field4>false</field4></item></xml>
 ',
                '<?xml version="1.0" encoding="utf-8"?>
@@ -408,10 +411,18 @@ line 2","Value 3"',
     * @test
     * @dataProvider array_provider5
     */
-   public function test_to_xml_boolean($array, $default, $true, $number)
+ public function test_to_xml_boolean($array, $default, $default_php7, $true, $number)
    {
        // default
-       $this->assertEquals($default, Format::forge($array)->to_xml());
+     if (version_compare(PHP_VERSION, '6.99.99') > 0)
+     {
+         $this->assertEquals($default_php7, Format::forge($array)->to_xml());
+     }
+     else
+     {
+         $this->assertEquals($default, Format::forge($array)->to_xml());
+     }
+
        // true/false
        $this->assertEquals($true, Format::forge($array)->to_xml(null, null, null, null, true));
        // 1/0

[Edited] changed compared version.

@WanWizard
Copy link
Member

I would prefer something like

if (PHP_VERSION_ID >= 70000)

instead. Seeing a PHP 6 version being referred to always looks funny...

@kenjis
Copy link
Contributor Author

kenjis commented Oct 23, 2015

This failure has nothing related with php7. But it is because of old libxml version.
See #1944

@ji1t
Copy link

ji1t commented Jun 9, 2019

Fatal error: Uncaught Error: Call to undefined method Error::error_handler() in /home/hostname/public_html/folder/fuel/core/bootstrap.php:48 Stack trace: #0 /home/hostname/public_html/folder/fuel/core/vendor/phpseclib/Crypt/AES.php(467): {closure}(8192, 'Function mcrypt...', '/home/hostname/...', 467, Array) #1 /home/hostname/public_html/folder/fuel/core/vendor/phpseclib/Crypt/AES.php(279): PHPSecLib\Crypt_AES->_mcryptSetup() #2 /home/hostname/public_html/folder/fuel/core/classes/crypt.php(107): PHPSecLib\Crypt_AES->encrypt('a:3:{i:0;a:6:{s...') #3 /home/hostname/public_html/folder/fuel/core/classes/session/driver.php(459): Fuel\Core\Crypt::encode('a:3:{i:0;a:6:{s...') #4 /home/hostname/public_html/folder/fuel/core/classes/session/cookie.php(111): Fuel\Core\Session_Driver->_set_cookie(Array) #5 [internal function]: Fuel\Core\Session_Cookie->write('', Array) #6 /home/hostname/public_html/folder/fuel/core/classes/event/instance.php(163): call_user_func(Array, '', Array) #7 /home/hostname/public_html/wor in /home/hostname/public_html/folder/fuel/core/bootstrap.php on line 48

@RyanSacks
Copy link

@ji1t
I know this was a while ago, but were you able to solve this issue? I'm using php 5.6 and still getting this issue.

@WanWizard
Copy link
Member

WanWizard commented Jun 28, 2023

The above error was triggered in phpseclib.

You have to be careful when using external components with PHP versions as ancient as 5.6.

Having said that, we still have maintained apps running on 5.6, so it is not framework related, but an issue in your specific environment. What will require some debugging...

@RyanSacks
Copy link

@WanWizard
I switched php versions using the command line instead of Apache. So php -v was showing me 5.6, but after checking the version using phpinfo() I saw that there it still said 7.4. Now everything is working again. Thank you.

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

No branches or pull requests

5 participants