• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Failed To Open Stream: No such file or directory (application/errors/error_php.php)

#1
[eluser]J. Pavel Espinal[/eluser]
I have just downloaded a fresh copy of CodeIgniter in order to build a quick application and, while trying to see if had php5-imap library installed I wrote this simple code:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mailer {
    
    function __construct() {
        
    }
    
    public function foo() {
        $mbox = imap_open ("{mail.example.com:143}", "[email protected]", "123456");
        var_dump($mbox);
        echo "<br/>";
        echo BASEPATH . "<br/>";;
        echo APPPATH  . "<br/>";
    }
}

/* End of file Mailer.php */

Then, on a very simple controller I tried to invoke that method:

Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Main extends CI_Controller {
    
    /**
     * Main Controller constructor
     */
    function __construct() {
        parent::__construct();
        $this->load->library('mailer');
    }
    
    public function index() {
        $this->mailer->foo();
    }
    
}

Then, after failing to connect (which is normal, because of the domain used as imap server), it fails to include one CodeIgniter files (error_php.php).

This is the output of the script:
Quote:bool(false)
/var/www/poster/system/
application/
Warning: include(application/errors/error_php.php): failed to open stream: No such file or directory in /var/www/poster/system/core/Exceptions.php on line 182 Call Stack: 0.0281 2404088 1. _exception_handler() /var/www/poster/system/core/Common.php:0 0.0281 2404168 2. CI_Exceptions->show_php_error() /var/www/poster/system/core/Common.php:487 Warning: include(): Failed opening 'application/errors/error_php.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/poster/system/core/Exceptions.php on line 182 Call Stack: 0.0281 2404088 1. _exception_handler() /var/www/poster/system/core/Common.php:0 0.0281 2404168 2. CI_Exceptions->show_php_error() /var/www/poster/system/core/Common.php:487

Is it normal that it fails to reach 'error_php.php' file when the error occurs inside a library?

Thanks in advance.

#2
[eluser]J. Pavel Espinal[/eluser]
Interesting enough, if I trigger the error inside the library with fopen() function, the behavior is different (It does finds error_php.php).

Ex.

Code:
public function foo() {
        //$mbox = imap_open ("{mail.example.com:143}", "[email protected]", "123456");
        $mbox = fopen('/tmp/i-do-not-exist','r');
        var_dump($mbox);
        echo "<br/>";
        echo BASEPATH . "<br/>";;
        echo APPPATH  . "<br/>";
    }

#3
[eluser]J. Pavel Espinal[/eluser]
For the record, imap_open will throw any errors occurred (even if you try to silence it up with "@", e.g. @imap_open(...)) at least that you capture the array of error messages immediately after, with something like:

Code:
public function foo() {
        $lrMbox = imap_open("{mail.example.com:143}", "[email protected]", "123456");
        $laErrors = imap_errors();
        $laAlerts = imap_alerts();

        ...
    }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.