Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#1486279 closed Bugs (fixed)

Bug in INSERT/UPDATE/DELETE queries on MySQLi

Reported by: dupondje Owned by:
Priority: 7 Milestone: 0.4-stable
Component: Database Version: 0.3.1
Severity: major Keywords: mysql, insert, update, delete, problems, 5.3
Cc: info@…, info@…, danger@…, dennylin93@…

Description

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

Attachments (2)

mysqli-0.3.1.php.patch (1.1 KB) - added by dennylin93 4 years ago.
Patch to make RC 0.3.1 work with PHP 5.3, bind_param() requires pass by reference instead of pass by value
mysqli-trunk.php.patch (688 bytes) - added by dennylin93 4 years ago.
Check if $result is not true since call_user_func_array() returns NULL when an error is encountered while parsing parameters

Download all attachments as: .zip

Change History (27)

comment:1 Changed 5 years ago by dupondje

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

comment:2 Changed 5 years ago by alec

  • Component changed from Addressbook to Database
  • Milestone changed from later to 0.4-beta

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

comment:3 Changed 5 years ago by dupondje

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

comment:4 Changed 5 years ago by dupondje

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

Btw ... Is the newest stable.

comment:5 Changed 5 years ago by alec

Just try with 2.5.0b2.

comment:6 Changed 5 years ago by dupondje

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

comment:7 Changed 5 years ago by alec

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.

comment:8 Changed 5 years ago by dupondje

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

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

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

SET last_login=now()
WHERE user_id=?]

[Native code: 0]

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

[06-Nov-2009 08:26:02 +0100]: DB Error: MDB2 Error: unknown error Query: _execute: [Error message: Unable to execute statement] [Last executed query: DELETE FROM session WHERE sess_id=?] [Native code: 0] in /usr/share/roundcubemail/program/include/rcube_mdb2.php on line 627 (POST /?_task=&_action=login)
[06-Nov-2009 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
[06-Nov-2009 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

comment:9 Changed 5 years ago by dupondje

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

comment:10 Changed 5 years ago by sbarakat

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.

comment:11 Changed 5 years ago by alec

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.

comment:12 Changed 5 years ago by dupondje

  • Cc info@… added

[Thu Nov 19 10:11:53 2009] [error] [client 194.78.167.235] MDB2 Error: unknown error (-1): _execute: [Error message: Unable to execute statement]\n[Last executed query: INSERT INTO session\n (sess_id, vars, ip, created, changed)\n VALUES (?, ?, ?, FROM_UNIXTIME(1258621913), FROM_UNIXTIME(1258621913))]\n[Native code: 0]\n, referer: http://roundcube.dupie.be/?_task=mail
[Thu Nov 19 10:11:53 2009] [error] [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
[Thu Nov 19 10:11:53 2009] [error] [client 194.78.167.235] PHP Notice: MDB2 Error: unknown error Query: _execute: [Error message: Unable to execute statement] [Last executed query: INSERT INTO session (sess_id, vars, ip, created, changed) VALUES (?, ?, ?, FROM_UNIXTIME(1258621913), FROM_UNIXTIME(1258621913))] [Native code: 0] in /usr/share/roundcubemail/program/include/bugs.inc on line 86, referer: http://roundcube.dupie.be/?_task=mail
[Thu Nov 19 10:11:56 2009] [error] [client 194.78.167.235] MDB2 Error: unknown error (-1): _execute: [Error message: Unable to execute statement]\n[Last executed query: INSERT INTO session\n (sess_id, vars, ip, created, changed)\n VALUES (?, ?, ?, FROM_UNIXTIME(1258621916), FROM_UNIXTIME(1258621916))]\n[Native code: 0]\n, referer: http://roundcube.dupie.be/?_task=mail
[Thu Nov 19 10:11:56 2009] [error] [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
[Thu Nov 19 10:11:56 2009] [error] [client 194.78.167.235] PHP Notice: MDB2 Error: unknown error Query: _execute: [Error message: Unable to execute statement] [Last executed query: INSERT INTO session (sess_id, vars, ip, created, changed) VALUES (?, ?, ?, FROM_UNIXTIME(1258621916), FROM_UNIXTIME(1258621916))] [Native code: 0] in /usr/share/roundcubemail/program/include/bugs.inc on line 86, referer: http://roundcube.dupie.be/?_task=mail

=> APACHE LOGS

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

SET last_login=now()
WHERE user_id=?]

[Native code: 0]

=> RCUBE logs ...

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

comment:13 Changed 5 years ago by volker

subscribed

comment:14 Changed 4 years ago by mcgege

  • Cc info@… added

comment:15 follow-up: Changed 4 years ago by danger

I can confirm this bug on roundcube 0.3.1 with php 5.3.2

comment:16 Changed 4 years ago by danger

  • Cc danger@… added

comment:17 Changed 4 years ago by dennylin93

  • Cc dennylin93@… added

comment:18 in reply to: ↑ 15 Changed 4 years ago by dennylin93

Replying to danger:

I can confirm this bug on roundcube 0.3.1 with php 5.3.2

Same here.

comment:19 Changed 4 years ago by dennylin93

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

comment:20 Changed 4 years ago by alec

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

comment:21 Changed 4 years ago by dennylin93

After some testing, I found out that the errors go away if $rcmail_configsql_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.

comment:22 Changed 4 years ago by dennylin93

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)".

comment:23 Changed 4 years ago by dennylin93

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.

Changed 4 years ago by dennylin93

Patch to make RC 0.3.1 work with PHP 5.3, bind_param() requires pass by reference instead of pass by value

Changed 4 years ago by dennylin93

Check if $result is not true since call_user_func_array() returns NULL when an error is encountered while parsing parameters

comment:24 Changed 4 years ago by alec

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:25 Changed 4 years ago by danger

I can confirm that it works in 0.4-beta

Note: See TracTickets for help on using tickets.