Search code examples
phpcakephpbasic-authentication

Upgrading CakePHP web site to PHP 7


I've taken over a website written for PHP 5.4 and Cake2.x. I upgraded PHP to 7.2 and Cake to 2.10. Now no one can log in. I started debugging but I feel like I'm going down a rabbit-hole. In FormAuthenticate::authenticate(CakeRequest $request, CakeResponse $response) is the statement $fields = $this->settings['fields']; after which I added $ex = fopen('php://stderr', 'a'); fputs($ex, "fields=" . json_encode($fields) . "\n"); which output

fields={"username":"username","password":"password"}

rather than the actual username and password which I'd typed on the web page. I tried re-assigning fields with the actual username and password but the function calls method _checkFields which calls $request->data which returns an empty string.

Obviously I am taking the wrong approach here. I've done something wrong in the upgrade, or omitted to do something; something beyond just changing composer.json and running composer update. Any suggestions?


Solution

  • I've solved this problem by downgrading CakePHP to version 2.9.9.