Fatal Error. Uncaught error: Class 'CI_Controller' not found |
So this is a kinda old project running CI3 and we're facing this issue. It's very sporadic, it seems like it happens when requesting Ajax routes and the temporary fix testers have found is to "Clear the browser's cache".
From what I can see, people that faced this exact error and reported on StackOverflow have so many different causes too far and between, so I couldn't pinpoint the exact issue. Of course we don't touch core files, just extend from them in our own controllers, and the fact that it happens at random doesn't help to the issue. This is a screenshot of what we see in one of the Ajax responses: This stack trace points to this file called MY_Exceptions.php which has this code, reading another issue report here I kinda thought it was because at this point in the lifecycle CI_Controller wasn't loaded, but this is an Ajax call though, wouldn't the Core components be up even before my code is executed at that point?: Again, let me emphasize that this doesn't happen all the time with all the existing Ajax requests, nor consistently through all the user machines and browsers, it just happens, a browse cache clear and it's working as intended again. What you read previously is the original post on Stack Overflow and Github repo, but I did some further testing: I tried something, which was removing the file MY_Exception, thinking it wasn't being really used/referenced anywhere and it was just being loaded as a result of a line batch loading the files of a folder in codeigniter, also, that it seemed to be made by one of the previous developers of this project. Turns out it's absolutely needed, any Exception thrown in the project goes through this file, so everything was breaking in it's absence. Now, that got me thinking, this CI error is happening on the development environment after any exception is thrown out? maybe? that would've been worrysome because that would compromise the entire try - catch structure we have in the code, fortunatelly it wasn't the case, I forced a condition to throw an Exception and it worked just fine. But that puts us to the beginning, the only thing we know is that this is a random thing we can't catch just yet, I'll even say more, our tester said last week he got the CI error in another random place, but a couple hours later when I told him to check something for me, he went to test it again and it wasn't happening anymore, he didn't even need to clear cache. Can you people help me try to find the cause of this issue? thanks in advance
To troubleshoot this sporadic issue with CodeIgniter 3 (CI3) and Ajax requests, consider the following steps:
|
Welcome Guest, Not a member yet? Register Sign In |