问题描述:

We have a site that we're moving to a new server. Everything worked fine on the old server. It's just the start of a site, so it's pretty bare-bones.

When moving to our new server, trying to log-in no longer works. BUT - according to debugKit, the query generated by $this->Auth->login():

SELECT `User`.`id`, `User`.`name`, `User`.`email`, `User`.`username`, `User`.`password`, `User`.`role`, `User`.`created`, `User`.`modified`

FROM `shopping_main`.`users` AS `User`

WHERE `User`.`username` = 'another'

AND `User`.`password` = '3813dd3a5eeb39c857d56f9ae58ec7f8237e5eb3'

LIMIT 1

IS returning 1 row - yet this if block fails:

if ($this->Auth->login()) {

$this->Session->setFlash(__('You are now logged in.'));

} else {

$this->Session->setFlash(__('Invalid username or password, try again'));

}

PDO is installed on both (same version) - not sure if that matters, but we've had weird issues before w/ that.

When doing a fresh install of CakePHP 2.2 stable, everything lights up green (database connection, modrewrite...etc etc.)

I would have thought there was something wrong with our data, or code...etc, but - it's the same data, the same code, and that's verified by the fact that it DOES return 1 row.

Below is my most recent $components array in the AppController:

public $components = array(

'DebugKit.Toolbar',

'Session',

'Cookie',

'Auth' => array(

'loginRedirect' => array('controller' => 'dashboard', 'action' => 'index', 'admin'=>true),

'logoutRedirect' => array('controller' => 'users', 'action' => 'login', 'admin'=>true)

)

);


UPDATE:

According to our server guy, the server we're having the issue on is the only one with PECL intalled - when he removed it, the login worked. (We need it on the server for other things - why/what would cause that to keep our login from working?)

网友答案:

Answer by Original Poster (me):

According to our server guy, "There are two ways to load PDO. The first is by using easyapache to install the PDO php extension. The second is by installing the PDO via PECL. It appears that the modules in question are different."

Apparently, this server had PECL on it instead of the normal easyapache PDO. When he removed that, and restarted/reset it with the easyapache PDO, everything worked great.

So - sounds like CakePHP requires the "normal" PDO.

Mystery solved.


If you have PECL instead, you can use this workaround:

  1. Create a file "HpMysql.php" in your Datasource folder and add this code/class: https://github.com/lorenzo/HipHop/blob/master/Model/Datasource/Database/HpMysql.php

  2. Change your database.php 'datasource' to 'HpMysql'

相关阅读:
Top