Deleting user causes mysql error

lasac - November 8, 2009 - 10:04
Project:Privatemsg
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

When deleting a user the following error shows up

# user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: DELETE FROM pm_index WHERE mid IN () in /var/www/vhosts/greatmedia.nl/subdomains/###/httpdocs/sites/all/modules/privatemsg/privatemsg.module on line 1251.

#1

lasac - November 8, 2009 - 15:17

i'm no php-hero but what could be wrong with this line??

      db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids);

#2

Berdir - November 8, 2009 - 17:14

The issue is that $mid is empty, aka, the user has not written any messages. This is a bug.

The only thing that needs to be done is to wrap that line inside a "if (!empty($mids) { ". If you can, you are welcome to create a patch if not, I'll do it soon myself. Probably tomorrow.

#3

lasac - November 8, 2009 - 17:46

O no problem if that is the only thing to do, i will create a patch. How do i deliver a patch? just upload it here ?

#4

Berdir - November 8, 2009 - 17:51

Yes, just uploading is fine. See http://drupal.org/patch/create if you don't know how to create a patch.

#5

lasac - November 8, 2009 - 20:34

I have read http://drupal.org/patch/create but thats to technical for me. I have altered the file and uploaded it here. Works fine.

AttachmentSize
privatemsg.module.patch 78.61 KB

#6

Berdir - November 9, 2009 - 15:13
Status:active» needs review

Thanks, but that doesn't help me much since I need to patch file to review your changes.

Attached is a patch that also contains a test case which triggers the bug. Please test.

AttachmentSize
user_without_messages_fix.patch 2.39 KB

#7

Berdir - November 9, 2009 - 20:12
Status:needs review» fixed

Fixed in 6.x-1.x-dev. 7.x-1.x-dev does not yet contain that feature, I will integrate the bug fix directly into #559180: Delete messages and settings when a user is deleted.

#8

System Message - November 23, 2009 - 20:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.