2016-05-02 15 views
2

PHP 5.6でCodeIgniter 3.0.0を使用していました。CodeIgniter CI_Exceptions :: PHP 7にアップデートした後のshow_exceptionエラー

昨日、私はPHP 7に更新し、次のエラーを取得開始しました: -

Uncaught TypeError: Argument 1 passed to CI_Exceptions::show_exception() must be 
an instance of Exception, instance of Error given, called in /my/file/path/app/system/core/Common.php on line 658 and defined in /my/file/path/hgx_portal/app/system/core/Exceptions.php:190 
Stack trace: 
#0 /my/file/path/hgx_portal/app/system/core/Common.php(658): CI_Exceptions->show_exception(Object 
(Error)) 
#1 [internal function]: _exception_handler(Object(Error)) 
#2 {main} 
    thrown in /my/file/path/hgx_portal/app/system/core/Exceptions.phpon line 190 
+0

Codeigniter 3.06にアップグレードしてください。それでもエラーが発生した場合は、codeigniter.comフォーラムに投稿してください。 – cartalot

+0

実際、私はCI 3.06にアップグレードできません。私はPHP 5.6にロールバックする必要があると思う。 –

+0

CI 3.0は1年以上経過しているので、できるときにアップグレードすることをお勧めします。 – cartalot

答えて

7

これは、CodeIgniterの3.0.0における既知の問題であり、下のgithubの問題herechangelogを参照してください。

Fixed a bug (#4137) - :doc: Error Handling <general/errors> breaks for the new Error exceptions under PHP 7.

イッツset_exception_handler()changed behavior PHP 7.

Code that implements an exception handler registered with set_exception_handler() using a type declaration of Exception will cause a fatal error when an Error object is thrown.

If the handler needs to work on both PHP 5 and 7, you should remove the type declaration from the handler, while code that is being migrated to work on PHP 7 exclusively can simply replace the Exception type declaration with Throwable instead.

<?php 
// PHP 5 era code that will break. 
function handler(Exception $e) { ... } 
set_exception_handler('handler'); 

// PHP 5 and 7 compatible. 
function handler($e) { ... } 

// PHP 7 only. 
function handler(Throwable $e) { ... } 
?> 
理由

3.0.2以降のものにアップグレードすると、問題が解決されます。

+0

なぜ閉鎖された問題にリンクしていますか? – cartalot

+0

申し訳ありませんが、問題は3.0.2で修正されただけで、上記の質問には3.0.0が実行されていることが明確に示されています。 –

+1

そして、CI 3.00が最初のPHP 7 alphaの数か月前にリリースされたという細かいことがあります。 – cartalot

関連する問題