Ion Auth/CodeIgniter 致命错误:调用了未定义的方法 Ion_auth::get_user()

发布于 2024-12-14 20:00:55 字数 1760 浏览 1 评论 0原文

尝试访问我的 planner.php 和 shared.php 控制器时收到此致命错误。有什么想法吗?

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

我用于 Ion Auth 的库扩展: 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

Receiving this fatal error when trying to access my planner.php and shared.php controllers. Any thoughts?

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

Library Extension I'm Using for Ion Auth:
http://jondavidjohn.com/blog/2011/01/scalable-login-system-for-codeigniter-ion_auth

Planner Controller:
http://pastie.org/private/wc1bq6eiqb9hn8iubwdgq

Shared Controller:
http://pastie.org/private/uj3ta8dw3jl7kqxizs9n1a

Ion_auth Library Line 88 Segment:
http://pastie.org/private/mhgwdzjyhatwsdrux4gqpa

CRUD Model:
http://pastie.org/private/m2nhfqzabdsx5eiz6xqupw

Events Model:
http://pastie.org/private/b6ksjoowl7wde9errow

Shared Model:
http://pastie.org/private/f741jfnf8o2l5oxphnrl5w

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤檠 2024-12-21 20:00:55

嗯,同样的事情也发生在我身上。在该库的最新版本中,Ben Edmunds 使用了 php 魔术方法 __call(),这样您就不必使用常规语法 $this->ion_auth_model 来调用模型的方法->method() 但使用 $this->ion_auth->method(),就好像它是属于库的方法一样。

但实际上,该方法属于模型。因此,如果您查看模型,您会发现没有 get_user() 方法(库中也没有!),或者至少在我谈论的版本中(最新的或之前我一两周前下载的新副本)。
我认为他提供的文档中有一些错误(尽管他所做的整体工作很棒,向 Ben 致敬)。

您可以尝试使用 user() 模型方法,它应该产生相同的结果(它的功能更接近)。因此,请调用 $this->ion_auth->user() 并查看是否符合您的需求。

编辑

为了澄清...而不是这个...

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

这样做...

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

Uhm, it happened to me the same exact thing. In the latest releases of this library, Ben Edmunds used php magic method __call() so that you don't have to call a model's method by using the regular syntax $this->ion_auth_model->method() but using instead $this->ion_auth->method(), as if it was a method belonging to the library.

But, actually, that method belongs to the model. So, if you go have a look at the model, you'll see that there's no get_user() method (nor is there in the library!), or at least in the version I talk about (the latest or the one just before. I downloaded a fresh copy one or two weeks ago).
I think there are some errors in the documentation he provided (though the overall work he did is awesome, kudos to Ben).

You can try using the user() model method, which should yield to the same result (it's the closer in functionality). So call $this->ion_auth->user() and see if that fits your needs.

EDIT

To clarify... instead of this...

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

do this...

$this->end_user = $this->ion_auth->user()->row();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文