Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: Simon9863 on December 31, 2005, 06:43:50 PM

Title: Cannot delete topic (RC2)
Post by: Simon9863 on December 31, 2005, 06:43:50 PM
Hi All,

Just upgraded to RC2 on a fedora 4 server, running php511 and mysql 5.018

I've always used the default mysql rpm packages and have never had problems, yet when trying to delete a topic, then i am getting this error

Database Error: Lost connection to MySQL server during query
File: pathto/forum/Sources/RemoveTopic.php
Line: 355Database Error: MySQL server has gone away
File: pathto/forum/Sources/Load.php
Line: 1886"

Also, when deleting a reply to a topic, then i get a blank screen, yet the reply is deleted...


I have no problems with any other function in the software, so wonder whether this is really an incorrect server configuration, as suggested in the help pages here etc.

I hyave no mods installed, and these are the official mysql rpm's not the redhat versions.

Can anyone possibly give me some idea's on this one please ?

Many thanks,
Regards
Simon
Title: Re: Cannot delete topic (RC2)
Post by: JayBachatero on December 31, 2005, 06:46:49 PM
Make sure that all files got overwriten. 
In your admin panel click on (more info) and it will tell you if your files are up to date.

-JayBachatero
Title: Re: Cannot delete topic (RC2)
Post by: Simon9863 on December 31, 2005, 09:21:35 PM
Hi there, every file is up to date and was overwritten before the upgrade, yet we're still having these problems, sadly :(


Hope the answer is out there somewhere :)

Thanks again,
Regards
Simon
Title: Re: Cannot delete topic (RC2)
Post by: JayBachatero on December 31, 2005, 09:30:30 PM
I will report this to a Dev so that he can take a closer look into this.

-JayBachatero
Title: Re: Cannot delete topic (RC2)
Post by: Grudge on January 01, 2006, 04:43:34 AM
Simon,

That's a little odd - same message each time?

This query:

db_query("
DELETE FROM {$db_prefix}messages
WHERE ID_TOPIC $condition", __FILE__, __LINE__);


Seems to be causing it, but it's not a difficult one. How large is your forum? If you'd be so kind as to provide me with an admin account and phpMyAdmin access I may have a better change of debugging it.

Cheers,

Grudge
Title: Re: Cannot delete topic (RC2)
Post by: Simon9863 on January 01, 2006, 12:09:36 PM
Thanks, Grudge

I've sent you a PM with the relevent access details as per you request. Hope you can find the cause of this problem !


Many thanks :)
Regards
Simon
Title: Re: Cannot delete topic (RC2)
Post by: Grudge on January 01, 2006, 01:28:17 PM
Simon,

I've fixed it, but I think this *may* actually be a bug with the MySQL you are running. I basically worked around it. It was actually an attachments query which was failing. Whenever using WHERE attachmentType = in the query, it lost connection to the server. I fixed it by changing these lines in RemoveTopic.php:

removeAttachments('a.attachmentType = '0' AND m.ID_TOPIC ' . $condition, 'messages');


To:

removeAttachments('a.attachmentType = \'0\' AND m.ID_TOPIC ' . $condition, 'messages');


However, that should NOT be needed, it's effectively casting the 0 as a string, although attachmentType is an integer - very, very odd.

Grudge

EDIT:  You need to make these changes to Post.php file.
Find a.attachmentType = 0
Replace a.attachmentType = \'0\'
Title: Re: Cannot delete topic (RC2)
Post by: Simon9863 on January 01, 2006, 01:33:18 PM
Thats great work Grudge !


Many, many thanks for finding this error.

These are official MySQL Rpm's as on MySQL's website, so should i report this as a mysql bug do you think ? If so, then how would i describe this to them ?


Many thanks again, i really was clueless on this one !

Regards
Simon
Title: Re: Cannot delete topic (RC2)
Post by: Grudge on January 01, 2006, 01:45:59 PM
The query that failed was this:

SELECT
a.filename, a.attachmentType, a.ID_ATTACH, a.ID_MEMBER, a.ID_MSG,
IFNULL(thumb.ID_ATTACH, 0) AS ID_THUMB, thumb.filename AS thumb_filename, thumb_parent.ID_ATTACH AS ID_PARENT
FROM (cvssmf_attachments AS a)
LEFT JOIN cvssmf_attachments AS thumb ON (thumb.ID_ATTACH = a.ID_THUMB)
LEFT JOIN cvssmf_attachments AS thumb_parent ON (a.attachmentType = 3 AND thumb_parent.ID_THUMB = a.ID_ATTACH)
WHERE a.attachmentType = 0
AND a.ID_MSG = 2230

So could ask them why. I'll upgrade my MySQL install a sec and see if it breaks for me...

Update: Upgraded MySQL to 5.0.18-nt and worked fine :/
Title: Re: Cannot delete topic (RC2)
Post by: Simon9863 on January 01, 2006, 06:51:19 PM
Hmmm, i used the generic Linux x86 RPM's, as i don't run Windows on my server.


I wonder if anyone else has had a problem with these RPM's, apart from me ?

Title: Re: Cannot delete topic (RC2)
Post by: korruption on January 09, 2006, 04:38:47 PM
I had the same problem, I made the change that Grudge suggested to the RemoveTopic.php that fixed it. Then after trying to modify a post I ran into the same problem with the Post.php file.
So I disabled attachments on the board and all the problems went away.

I am running PHP 5.1.1, MySQL 5.0.18 and Apache 2.2.0 on Debian 3.1.
PHP and Apache were installed from source MySQL is latest bin dist.

I dont know if the prob is with MySQL 5 or what as I havent had a chance to test it with 4.1.
Title: Re: Cannot delete topic (RC2)
Post by: tiko on March 19, 2006, 12:10:35 PM
Hello,

Digging up an old topic here, but I'm having the same problem as apparently many others are having.  I'm receiving the same error, but additionally the error is causing my mysql server to restart itself, as well as some other quirks that cause the post count to be completely inaccurate.  Also, any other posts in the category are hidden (seemingly removed) until I recount forum totals/stats from within the admin panel.

My configuration is:
FreeBSD 6.0
Apache 2.0.55
PHP 4.4.2
MySQL 5.0.19, built with FreeBSD ports

I have not applied Grudge's fix yet, but was curious if any progress has been made to track down this problem.

Thanks.
Title: Re: Cannot delete topic (RC2)
Post by: JayBachatero on March 19, 2006, 12:26:36 PM
Try applying Grudge's fix.
Title: Re: Cannot delete topic (RC2)
Post by: JuhaS14 on March 21, 2006, 01:59:54 PM
I have tried with 5.0.19 and 5.0.18 Mysql and get same error in Debian.
Title: Re: Cannot delete topic (RC2)
Post by: JuhaS14 on March 21, 2006, 02:07:08 PM
Same kind of problem when i try to remove post (not topic), it deleted post but gives me error message:

Tietokantavirhe: MySQL server has gone away
Tiedosto: /var/www/forum/Sources/Subs.php
Rivi: 419Tietokantavirhe: MySQL server has gone away
Tiedosto: /var/www/forum/Sources/Load.php
Rivi: 1886
Title: Re: Cannot delete topic (RC2)
Post by: JayBachatero on March 25, 2006, 12:49:13 AM
Can you please port a copu of your Load.php?
Title: Re: Cannot delete topic (RC2)
Post by: JuhaS14 on March 26, 2006, 12:25:21 PM
Quote from: JayBachatero on March 25, 2006, 12:49:13 AM
Can you please port a copu of your Load.php?

Sure, here: http://www.dnsf.org/forum/Sources/load.phps

Title: Re: Cannot delete topic (RC2)
Post by: JayBachatero on March 26, 2006, 12:40:39 PM
Sorry wrong file.  It's RemoveTopic.php
Title: Re: Cannot delete topic (RC2)
Post by: JuhaS14 on March 31, 2006, 03:17:08 AM
Quote from: JayBachatero on March 26, 2006, 12:40:39 PM
Sorry wrong file.  It's RemoveTopic.php

here: http://www.dnsf.org/forum/Sources/RemoveTopic.phps
Title: Re: Cannot delete topic (RC2)
Post by: Kuzmitch on March 31, 2006, 03:52:13 AM
I have probably the same problems with the configuration. Please look at this topic: http://www.simplemachines.org/community/index.php?topic=79005.0

This fix (removeAttachments('a.attachmentType = \'0\' AND m.ID_TOPIC ' . $condition, 'messages');) was applied already.

Thankx!
Title: Re: Cannot delete topic (RC2)
Post by: Kuzmitch on March 31, 2006, 04:15:11 AM
Solved! I have searched through all files which include "attachmentType" and fixed slashes. Now it works!
Title: Re: Cannot delete topic (RC2)
Post by: JayBachatero on March 31, 2006, 09:02:11 AM
JahaS you forgot to change this one.

        // Delete attachment(s) if they exist.
        require_once($sourcedir . '/ManageAttachments.php');
        removeAttachments('a.attachmentType = 0 AND a.ID_MSG = ' . $message);  <====
    }
Title: Re: Cannot delete topic (RC2)
Post by: MadPax on April 03, 2006, 02:29:43 PM
Well thnx guys for the help and Xenovanis to point me here.

I did solve my problem apparantely, but I would really like to have a precise list of files and lines to alter in order to not to have any flaws in the future before doing this on my live site.

Anyone know exactly? I think this would serve other not so sure user types.

Thanx in advance,
Pax
Title: Re: Cannot delete topic (RC2)
Post by: tethead on April 17, 2006, 05:16:48 PM
i'm having the same problem, so i did the fix in the RemoveTopic.php but still had other problems with Subs.php so i just disabled attachments on our boards until further notice. 

can somebody please post an exact list of the files that need to be changed as a workaround to this MySQL bug, and what needs to be changed?

guess i should have read here before upgrading from MySQL 4.x to 5.x
Title: Re: Cannot delete topic (RC2)
Post by: JayBachatero on April 17, 2006, 05:20:00 PM
Did you edit both places that you had to edit?  That link that you are searching for comes out twice in that file.
Title: Re: Cannot delete topic (RC2)
Post by: tethead on April 17, 2006, 05:23:56 PM
it fails at line 419 of Subs.php , and i don't see anything dealing with attachments to edit around that... 

if you can please provide details for a semi-n00b on which files to change and what to change, i'd be very much appreciative!
Title: Re: Cannot delete topic (RC2)
Post by: tethead on April 17, 2006, 05:55:11 PM
btw, i'm running version 5.0.19 or MySQL and SMF 1.1 RC2 on a Debian (Sarge) server. 
Title: Re: Cannot delete topic (RC2)
Post by: JayBachatero on April 17, 2006, 07:07:08 PM
What error are you getting?
Title: Re: Cannot delete topic (RC2)
Post by: Simon9863 on April 17, 2006, 07:47:57 PM
Hmm, I upgraded to mysql 5.0.20 today and suddenly I can delete and modify again without problems.
Hopefully this bug has been solved, even though the MySQL bug report doesn't say this has been fixed.
Can anyone else having this problem verify that the bug has gone away with 5.0.20 ?

If so, then i'll add that to the bug submission at mySQL and close the report.

Thanks
Regards
Simon
Title: Re: Cannot delete topic (RC2)
Post by: tiko on April 18, 2006, 12:01:36 AM
Simon, after reading your post I upgraded my mysql installation to 5.0.20 as well.  I can confirm that the problem is gone using 5.0.20 (RC2 w/ most recent patch).
Title: Re: Cannot delete topic (RC2)
Post by: tethead on April 18, 2006, 10:04:14 AM
fixed here too!!  awesome!
Title: Re: Cannot delete topic (RC2)
Post by: Tikkas on May 10, 2006, 06:10:21 AM
I have the same problem. I fixed the reomovetopic and it worked fine after that.

Today however I wanted to edit a reply with and attach in it and got the same thing.
So I looked for the code in Post.php and changed it there too:

removeAttachments('a.attachmentType = '/0/' AND a.ID_MSG = ' . (int) $_REQUEST['msg'] . ' AND a.ID_ATTACH NOT IN (' . implode(', ', $del_temp) . ')');

That fixed the problem.

Just thought I would share it  ;)

cheers

Tikkas
Title: Re: Cannot delete topic (RC2)
Post by: Prime_8 on June 10, 2006, 06:14:43 PM
this code will cause your forum to remove all attachments
Quote from: Tikkas on May 10, 2006, 06:10:21 AM
removeAttachments('a.attachmentType = '/0/' AND a.ID_MSG = ' . (int) $_REQUEST['msg'] . ' AND a.ID_ATTACH NOT IN (' . implode(', ', $del_temp) . ')');

to fix simply use teh patter set  in earlier post
removeAttachments('a.attachmentType = \'0\' AND a.ID_MSG = ' . (int) $_REQUEST['msg'] . ' AND a.ID_ATTACH NOT IN (' . implode(', ', $del_temp) . ')');

see the diff ?

this will alow for safe removal of  an attachment from just the one post you are editing not every post in the forum .  ;)

Title: Re: Cannot delete topic (RC2)
Post by: mimicria on August 02, 2006, 12:59:54 AM
I have some messages about server down and lost connection with mysql

I use Mysql 5.0.18 and php 5 on linux server on SuSe 10.1 (SMF 1.1 RC2)

After reading some post on this site a solve all problems with my forum. Thanks for all authors !

You can solve problems:

Changing in ManageAttachments.php, Removetopics.php and maybe in other files ...

a.attachmentType = 0 AND m.ID_TOPIC

to

a.attachmentType = \'0\' AND m.ID_TOPIC

and changing in Removetopics.php (in my file line 557)

LEFT JOIN {$db_prefix}attachments AS thumb_parent ON (a.attachmentType = 3 AND thumb_parent.ID_THUMB = a.ID_ATTACH)

with no sumbols (') !

to
LEFT JOIN {$db_prefix}attachments AS thumb_parent ON (a.attachmentType = '3' AND thumb_parent.ID_THUMB = a.ID_ATTACH)
Title: Re: Cannot delete topic (RC2)
Post by: mxw65 on October 11, 2006, 01:25:50 PM
Quote from: Grudge on January 01, 2006, 01:28:17 PM

removeAttachments('a.attachmentType = '0' AND m.ID_TOPIC ' . $condition, 'messages');

To:

removeAttachments('a.attachmentType = \'0\' AND m.ID_TOPIC ' . $condition, 'messages');


Thanks a million. This fix worked for me as well.
Title: Re: Cannot delete topic (RC2)
Post by: auroris on January 06, 2007, 06:17:04 PM
Same problem here; the issues were that I could not edit a post containing an attachment and could not remove a topic. Grudge's fix worked. I am running Simplemachines 1.1.1; MySQL 5.1.6 on FreeBSD 6; PHP 5.2.0.

As an aside, an unmodified install of Simple Machines 1.0.10 on the same server using has no problems with attachments whatsoever.
Title: Re: Cannot delete topic (RC2)
Post by: HakTom on January 09, 2007, 05:34:58 AM
I can confirm this too.

running SMF 1.1.1, Mysql 5.0.18 on Debian, PHP 4.3.10
Title: Re: Cannot delete topic (RC2)
Post by: rulaman on April 24, 2008, 07:54:41 AM
Quote from: Grudge on January 01, 2006, 01:28:17 PM
Simon,

I've fixed it, but I think this *may* actually be a bug with the MySQL you are running. I basically worked around it. It was actually an attachments query which was failing. Whenever using WHERE attachmentType = in the query, it lost connection to the server. I fixed it by changing these lines in RemoveTopic.php:

removeAttachments('a.attachmentType = '0' AND m.ID_TOPIC ' . $condition, 'messages');


To:

removeAttachments('a.attachmentType = \'0\' AND m.ID_TOPIC ' . $condition, 'messages');


However, that should NOT be needed, it's effectively casting the 0 as a string, although attachmentType is an integer - very, very odd.

Grudge

EDIT:  You need to make these changes to Post.php file.
Find a.attachmentType = 0
Replace a.attachmentType = \'0\'


I had the same problem with my SMF 1.1.4.

Thanks for this workaround, it works fine ! ;)