cakephpmodelcakephp-1.3

CakePHP 1.3.7 - Renaming className in Model file breaks login page


I have an install of Cake 1.3.7 which I inherited from a previous developer for one of my clients. There is a model that includes the following:

var $belongsTo = array(
[. . .]
    'TimeSlot' => array(
        'className' => 'TimeSlot',
        'foreignKey' => 'time_slot',
    ),
[. . .]

I have renamed this model and class to OtherInfo, and changed the foreign key to other_info. All the appropriate files exist, the cache files have been refreshed, and I've successfully tested everything. The code above now looks like this:

var $belongsTo = array(
[. . .]
    'OtherInfo' => array(
        'className' => 'OtherInfo',
        'foreignKey' => 'other_info',
    ),
[. . .]

Everything works fine, until I log out of the software. At that point, the login page fails to load. Instead it gives me a generic "An Internal Error Has Occurred" message, which assigning a debug value in config.php doesn't seem to help with. However, if I rename className back to TimeSlot, the login page will load and I can log in. Once I'm logged back in, I can then rename className to OtherInfo again and the rest of the software will work just fine.

So I know exactly what line of code is causing the problem, but not why it causes a problem or what to do about it. Does anyone have any advice? I am a total novice in Cake and consider myself having done well for getting this far.


Solution

  • It turns out the solution is to delete the contents of the cache directories so that Cake can rebuild them. These directories are in app/tmp/cache/persistent/ and app/tmp/cache/models/