undefined model method does not rise error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: undefined model method does not rise error (/showthread.php?tid=75720) |
undefined model method does not rise error - carlorfeo - 03-09-2020 Hello, I've noticed that when you call a model->method that hasn't been defined, CI doesn't display any error (see the example below) PHP Code: $model = model('MyModel'); In my case, this is an undesired behavior, can be very tricky to debug I've solved the problem temporarily by commenting the definition of system/Model::__call() Is there a config parameter to control it? What is your opinion? EDIT: here's a workaround that keeps the model magics but rises error if you call an undefined method, hope this helps hack: PHP Code: elseif (method_exists($this, $name)) { complete method: PHP Code: public function __call(string $name, array $params) RE: undefined model method does not rise error - includebeer - 03-09-2020 I hope this is a bug. Because if this is intentional, like you say it will be hard to test and debug! I will try to reproduce this... RE: undefined model method does not rise error - InsiteFX - 03-10-2020 He's correct I just tried it here and it gave me no error also using the DebugToolBar. RE: undefined model method does not rise error - carlorfeo - 03-10-2020 Glad to see I'm not alone, so it seems it's not a desired behavior I've tested a workaround and added the code to the first post Though I'm not sure it could be a bugfix 'cause I don't know the system architecture that well RE: undefined model method does not rise error - InsiteFX - 03-10-2020 To learn the CodeIgniter architecture just open and follow the code in index.php and .\system\Codeigniter.php RE: undefined model method does not rise error - John_Betong - 03-10-2020 @carlorfeo, I think this is is a major BUG and dread to think of the other repercussions!!! > Is there a config parameter to control it? Code: # file: system/config/Services.php Output: Quote:Fatal error: Uncaught Error: Call to a member function initialize() on null in /var/www/ci4-strict.tk/system/CodeIgniter.php:190 RE: undefined model method does not rise error - carlorfeo - 03-13-2020 this bug has been fixed: https://github.com/codeigniter4/CodeIgniter4/issues/2688 RE: undefined model method does not rise error - includebeer - 03-14-2020 Cool, that was quick! |