From: Arnaud F. <ar...@cr...> - 2005-03-03 15:44:06
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, Since there is still prob. with sessions when using any SQL backend, I took a look at the code and found that, in order to check if there is already a session, DbSession performs an UPDATE and check if 1 line has been affected. If not, it performs an INSERT. Ok .. it's supposed to be more efficient that good old SELECT/UPDATE/INSERT method ... But for some reasons, it doesn't always work : in some cases, the AffectedRows method returns 0 even if there is a session already there. Then the INSERT fails ... So, unless you have a better idea, lets go back to the good old method. Here is a diff ... crao@raptor:~/web/phpwiki$ cvs diff lib/DbSession.php Index: lib/DbSession.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/DbSession.php,v retrieving revision 1.30 diff -r1.30 DbSession.php 204c204,208 < $res = $dbh->query("UPDATE $table" - --- | $res = $dbh->GetRow("SELECT sess_id FROM $table WHERE sess_id=$qid"); | | if ($res) { | | $res = $dbh->query("UPDATE $table" 207,209c211,213 < $result = $dbh->AffectedRows(); < if ( $result === false or $result < 1 ) { // 0 cannot happen, - -1 (failure) on mysql < $res = $dbh->query("INSERT INTO $table" - --- | } else { | | $res = $dbh->query("INSERT INTO $table" 212c216 < } - --- | } 419c423,425 < $rs = $dbh->Execute("UPDATE $table" - --- | $res = $dbh->GetRow("SELECT sess_id FROM $table WHERE sess_id=$qid"); | if($res) { | $rs = $dbh->Execute("UPDATE $table" 422,423c428 < $result = $dbh->Affected_Rows(); < if ( $result === false or $result < 1 ) { // false or int > 0 - --- | } else { -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCJzDZyAf3wgFyy1ARAhTIAKCon4DljeODt1L6/gLXNZW/GQSnMQCeLA2B UhhpWKe8dRDGA9jor968yUI= =1gHV -----END PGP SIGNATURE----- |