2011-11-12 50 views
1

嘗試訪問我的planner.php和shared.php控制器時收到此致命錯誤。有什麼想法嗎?Ion Auth/CodeIgniter致命錯誤

Fatal error: Uncaught exception 'Exception' with message 'Undefined method Ion_auth::get_user() called' in 
/application/libraries/Ion_auth.php:88 Stack trace: #0 

/application/core/MY_Controller.php(50): Ion_auth->__call('get_user', Array) #1 

/application/core/MY_Controller.php(50): Ion_auth->get_user() #2 

/application/controllers/user/planner.php(9): Common_Auth_Controller->__construct() #3 

/system/core/CodeIgniter.php(288): Planner->__construct() #4 /index.php(202): require_once('/Users/lrussell...') #5 {main} thrown in/application/libraries/Ion_auth.php on line 88 

圖書館推廣我使用離子驗證: http://jondavidjohn.com/blog/2011/01/scalable-login-system-for-codeigniter-ion_auth

規劃控制器: http://pastie.org/private/wc1bq6eiqb9hn8iubwdgq

共享控制器: http://pastie.org/private/uj3ta8dw3jl7kqxizs9n1a

Ion_auth圖書館線路88段: http://pastie.org/private/mhgwdzjyhatwsdrux4gqpa

CRUD型號: http://pastie.org/private/m2nhfqzabdsx5eiz6xqupw

活動型號: http://pastie.org/private/b6ksjoowl7wde9errow

共享型號: http://pastie.org/private/f741jfnf8o2l5oxphnrl5w

回答

2

嗯,它發生在我身上的同樣的事情。在這個庫的最新版本中,Ben Edmunds使用了php魔術方法__call(),這樣就不必使用常規語法$this->ion_auth_model->method()調用模型的方法,而是使用$this->ion_auth->method(),就好像它是屬於庫的方法。

但實際上,該方法屬於模型。所以,如果你看看這個模型,你會發現沒有方法(在圖書館也沒有!),或者至少在我談論的版本中(最新的或前一版的)。一兩週前下載了一份新的副本)。 我認爲他提供的文檔存在一些錯誤(儘管他做的整體工作非常棒,對Ben的讚譽)。

您可以嘗試使用user()模型方法,該方法應該產生相同的結果(它的功能越接近)。所以請致電$this->ion_auth->user(),看看是否符合您的需求。

編輯

澄清......不是這個......

$this->end_user = $this->ion_auth->current()->row(); 

做到這一點...

$this->end_user = $this->ion_auth->user()->row(); 
+1

我可以證實這一點,它直接關係到這最近提交到圖書館https://github.com/benedmunds/CodeIgniter-Ion-Auth/commit/ef733edb5ef396fec57fe363c5c8616506054c79 – jondavidjohn

+0

是的,所以從w ebsite benedmunds.com/ion_auth較舊,您必須直接從github下載文件以使其正常工作。感謝您的幫助! – imlouisrussell