Bug in INSERT/UPDATE/DELETE queries on MySQLi #2514

Closed
rcubetrac opened this Issue Nov 4, 2009 · 25 comments

1 participant

@rcubetrac

Reported by dupondje on 4 Nov 2009 17:17 UTC as Trac ticket #1486279

I got a problem with MySQLi on the 0.3.1 release.

I cannot login with MySQLi, when I change it to MySQL it just works without any problem.

I tracked down the error to the revision 2920.
When I revert the changes in http://trac.roundcube.net/changeset/2920/trunk/roundcubemail/program/include/rcube_mdb2.php everything works smooth again.

Is this a bug? Or what could be wrong? I'm using PHP 5.3

Keywords: mysql, insert, update, delete, problems, 5.3
Migrated-From: http://trac.roundcube.net/ticket/1486279

@rcubetrac

Comment by dupondje on 4 Nov 2009 17:19 UTC

Error log shows:
23:15:02 +0100: DB Error: MDB2 Error: unknown error Query: _execute: message: Unable to execute statement executed query: UPDATE users SET last_login=now() WHERE user_id=? code: 0 in /usr/share/roundcubemail/program/include/rcube_mdb2.php on line 628 (POST /?_task=&_action=login)
23:15:02 MDB2 Error: unknown error (-1): _execute: message: Unable to execute statement
executed query: DELETE FROM session WHERE sess_id=?
code: 0

@rcubetrac

Comment by @alecpl on 4 Nov 2009 18:01 UTC

No problem here with mysqli and PHP-5.2. Try newer MDB2 package http://pear.php.net/package/MDB2/download

@rcubetrac

Owner changed by @alecpl on 4 Nov 2009 18:01 UTC

=> none

@rcubetrac

Milestone changed by @alecpl on 4 Nov 2009 18:01 UTC

later => 0.4-beta

@rcubetrac

Comment by dupondje on 4 Nov 2009 18:28 UTC

Isn't the MDB2 lib included into the Roundcube package?

@rcubetrac

Comment by dupondje on 4 Nov 2009 19:07 UTC

Name : php-pear-MDB2-Driver-mysqli
Arch : noarch
Version : 1.4.1

Btw ... Is the newest stable.

@rcubetrac

Comment by @alecpl on 5 Nov 2009 07:32 UTC

Just try with 2.5.0b2.

@rcubetrac

Comment by dupondje on 5 Nov 2009 21:38 UTC

What MDB2 version is included in roundcube ? Why do I need external libs when there are included into roundcube?

@rcubetrac

Comment by @alecpl on 6 Nov 2009 07:12 UTC

I'm trying to help, so just check it, please. Roundcube is using 2.5.0b1, but there were some changes in the package. I'd like to know if update will fix your issue.

@rcubetrac

Comment by dupondje on 6 Nov 2009 07:29 UTC

Updated the MDB2 + mysqli plugin to 2.5.0b2, but it still doesn't work.

08:26:02 MDB2 Error: unknown error (-1): _execute: message: Unable to execute statement
executed query: DELETE FROM session WHERE sess_id=?
code: 0

08:26:02 +0100: DB Error: MDB2 Error: unknown error Query: _execute: message: Unable to execute statement executed query: DELETE FROM session WHERE sess_id=? code: 0 in /usr/share/roundcubemail/program/include/rcube_mdb2.php on line 627 (POST /?_task=&_action=login)
08:26:02 MDB2 Error: unknown error (-1): _execute: message: Unable to execute statement
executed query: UPDATE users
SET last_login=now()
WHERE user_id=?

code: 0

08:26:02 +0100: DB Error: MDB2 Error: unknown error Query: _execute: message: Unable to execute statement executed query: UPDATE users SET last_login=now() WHERE user_id=? code: 0 in /usr/share/roundcubemail/program/include/rcube_mdb2.php on line 627 (POST /?_task=&_action=login)
08:26:02 MDB2 Error: unknown error (-1): _execute: message: Unable to execute statement
executed query: DELETE FROM session WHERE sess_id=?
code: 0

08:26:02 +0100: DB Error: MDB2 Error: unknown error Query: _execute: message: Unable to execute statement executed query: DELETE FROM session WHERE sess_id=? code: 0 in /usr/share/roundcubemail/program/include/rcube_mdb2.php on line 627 (POST /?_task=&_action=login)
08:26:02 PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/roundcubemail/program/lib/MDB2.php on line 393
08:26:02 PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/roundcubemail/program/lib/MDB2.php on line 2647

@rcubetrac

Comment by dupondje on 6 Nov 2009 07:30 UTC

Oh and without the 2920 changeset it DOES work again ... even with 2.5.0b2.

@rcubetrac

Comment by sbarakat on 8 Nov 2009 14:05 UTC

I can also confirm I am getting the same issue. PHP v5.3.0, MySQLi, RC 0.3.1.
I first did an upgrade from 0.3-stable, that didn't work. So I tried a fresh install (fresh DB, latest package 0.3.1, reconfigured db.inc to mysqli:) and still experienced the same issue. I have now reverted back to mysql: which works.

@rcubetrac

Comment by @alecpl on 19 Nov 2009 08:41 UTC

Please, find in lib/MDB2/Driver/mysqli.php a line (1782):

if (!@mysqli_stmt_execute($this->statement)) {

and remove "@" sign. Maybe now this will print more helpful error message.

@rcubetrac

Comment by dupondje on 19 Nov 2009 09:16 UTC

Nov 19 10:11:53 2009 [client 194.78.167.235 MDB2 Error: unknown error (-1): _execute: message: Unable to execute statement\nexecuted query: INSERT INTO session\n (sess_id, vars, ip, created, changed)\n VALUES (?, ?, ?, FROM_UNIXTIME(1258621913), FROM_UNIXTIME(1258621913))\ncode: 0\n, referer: http://roundcube.dupie.be/?_task=mail
Nov 19 10:11:53 2009 [client 194.78.167.235 PHP Warning: Error writing to log file logs/errors; Please check permissions in /usr/share/roundcubemail/program/include/main.inc on line 1053, referer: http://roundcube.dupie.be/?_task=mail
Nov 19 10:11:53 2009 [client 194.78.167.235 PHP Notice: MDB2 Error: unknown error Query: _execute: message: Unable to execute statement executed query: INSERT INTO session (sess_id, vars, ip, created, changed) VALUES (?, ?, ?, FROM_UNIXTIME(1258621913), FROM_UNIXTIME(1258621913)) code: 0 in /usr/share/roundcubemail/program/include/bugs.inc on line 86, referer: http://roundcube.dupie.be/?_task=mail
Nov 19 10:11:56 2009 [client 194.78.167.235 MDB2 Error: unknown error (-1): _execute: message: Unable to execute statement\nexecuted query: INSERT INTO session\n (sess_id, vars, ip, created, changed)\n VALUES (?, ?, ?, FROM_UNIXTIME(1258621916), FROM_UNIXTIME(1258621916))\ncode: 0\n, referer: http://roundcube.dupie.be/?_task=mail
Nov 19 10:11:56 2009 [client 194.78.167.235 PHP Warning: Error writing to log file logs/errors; Please check permissions in /usr/share/roundcubemail/program/include/main.inc on line 1053, referer: http://roundcube.dupie.be/?_task=mail
Nov 19 10:11:56 2009 [client 194.78.167.235 PHP Notice: MDB2 Error: unknown error Query: _execute: message: Unable to execute statement executed query: INSERT INTO session (sess_id, vars, ip, created, changed) VALUES (?, ?, ?, FROM_UNIXTIME(1258621916), FROM_UNIXTIME(1258621916)) code: 0 in /usr/share/roundcubemail/program/include/bugs.inc on line 86, referer: http://roundcube.dupie.be/?_task=mail

=> APACHE LOGS

10:11:53 +0100: DB Error: MDB2 Error: unknown error Query: _execute: message: Unable to execute statement executed query: DELETE FROM session WHERE sess_id=? code: 0 in /usr/share/roundcubemail/program/include/rcube_mdb2.php on line 627 (POST /?_task=&_action=login)
10:11:53 MDB2 Error: unknown error (-1): _execute: message: Unable to execute statement
executed query: UPDATE users
SET last_login=now()
WHERE user_id=?

code: 0

=> RCUBE logs ...

Doens't make any difference in output it seems ...

@rcubetrac

Comment by volker on 14 Feb 2010 15:39 UTC

subscribed

@rcubetrac

Comment by danger on 16 Apr 2010 13:18 UTC

I can confirm this bug on roundcube 0.3.1 with php 5.3.2

@rcubetrac

Comment by dennylin93 on 18 Apr 2010 01:24 UTC

Replying to danger:

I can confirm this bug on roundcube 0.3.1 with php 5.3.2

Same here.

@rcubetrac

Comment by dennylin93 on 23 Apr 2010 15:03 UTC

I've been trying to trace the problem, might be related to this bug:
http://pear.php.net/bugs/bug.php?id=17270

@rcubetrac

Comment by @alecpl on 23 Apr 2010 17:46 UTC

I don't think so, we've got a problem with mysqli driver only.

@rcubetrac

Comment by dennylin93 on 24 Apr 2010 03:35 UTC

After some testing, I found out that the errors go away if $rcmail_config['sql_debug'] is set to TRUE.

The problem seems to be related to MDB2_PREPARE_MANIP as well.

Other than this, I haven't found out anything useful.

@rcubetrac

Comment by dennylin93 on 24 Apr 2010 06:31 UTC

Finally discovered the code that's causing this bug. A proper fix is still needed though.

If prepared statements are forced to be emulated using emulate_prepared, everything works, so the problem is in program/lib/MDB2/Driver/mysqli.php.

The code between lines 1111~1129 is the culprit since RC works when "if (!$is_manip)" is changed to "if (1)".

@rcubetrac

Comment by dennylin93 on 25 Apr 2010 00:12 UTC

This bug has already been fixed in trunk and beta-0.4 in revision 3354.

I've attached a patch for 0.3.1 and one for trunk that checks if $result is not true. Apparently call_user_func_array() returns NULL when an error occurs while parsing parameters, so checking for FALSE sometimes isn't enough.

This bug is also the same as http://bugs.php.net/bug.php?id=43568.

@rcubetrac

Comment by @alecpl on 30 Apr 2010 14:21 UTC

Finally, I've upgraded to 5.3 and I'm able to confirm it's fixed in svn-trunk version.

@rcubetrac

Status changed by @alecpl on 30 Apr 2010 14:21 UTC

new => closed

@rcubetrac rcubetrac closed this Apr 30, 2010
@rcubetrac

Comment by danger on 30 Apr 2010 14:44 UTC

I can confirm that it works in 0.4-beta

@rcubetrac rcubetrac added this to the 0.4-stable milestone Mar 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment