3

将 Ion Auth 与 Code Igniter 2.0 和 PHP 5.2 一起使用时出现以下错误

ErrorException [ Notice ]: Undefined property: Practice::$ion_auth
SYSDIR/core/Model.php [ 50 ]

这是该行的代码:

45      * @access private
46      */
47     function __get($key)
48     {
49         $CI =& get_instance();
50         return $CI->$key;
51     }
52 }
53 // END Model Class
54 
55 /* End of file Model.php */ 

关于这个错误的奇怪部分是,当我尝试访问一个“受限”页面而没有先访问同一域上的非受限页面时,它似乎会爬起来。也就是说,如果我打开浏览器并输入 example.com/restricted - 我会收到错误消息。但是,如果我输入 example.com/login 然后(即使我没有正确登录)转到 example.com/restricted,它将让我进入或正确重定向我(取决于我是否实际登录)。

我一生都无法弄清楚是什么引发了这个问题。这是我使用 Ion Auth 库的一些控制器的构造函数示例:

class Home extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->library('firephp');

        //ION
        $this->load->library('Ion_auth');
        $this->load->library('session');
        $this->load->library('form_validation');
        $this->load->database();
    }

class Practice extends CI_Controller {

    var $user;
    var $game;

    function __construct() {
        parent::__construct();

        // ION Auth
        $this->load->library('Ion_auth');
        $this->load->library('form_validation');
        $this->load->library('session');

        // Defaults
        $this->load->helper('url');
        $this->load->library('firephp');

        // Models
        //$this->load->model('Ion_auth_model');
        //$this->load->model('Player');
        $this->load->model('Practice_Game');



        // User must be logged in to use this controller
        // If user is logged in then we get his info as a class variable
        if ($this->ion_auth->logged_in()) {
            $this->user = $this->ion_auth->get_user($this->session->userdata('user_id'));
        } else {
4

1 回答 1

1

我遇到了同样的问题。当自动登录记住的登录并且 ion auth 尝试使用一些尚未加载的属性时,就会出现问题。

您可以查看此拉取请求和以下提交:

https://github.com/benedmunds/CodeIgniter-Ion-Auth/pull/46 https://github.com/benedmunds/CodeIgniter-Ion-Auth/commit/ba6d09299cd7469835ab3ad7fb1a4333de88d468

于 2011-06-22T10:16:21.003 回答