PDA

View Full Version : INSERTing a thread ?


galt
04-15-2002, 11:29 PM
As I proceed along with my work-along CMS, I now need to create new threads from outside of VB. So far I have learned that when I insert a thread row:

I need to set up an invisible forum to attach the threads to (threadid <> 0)

I must set open = 1 (talk about a lousy variable name !!)
I must set visible = 1

That gives me a postable thread.

By accident during testing, I discovered that this was not enough. When I tried to Administratively change the topic name of the thread, I got a fatal error with the VB programs:
*****
Database error in vBulletin 2.2.4:

Invalid SQL: DELETE FROM searchindex WHERE wordid IN (0) AND postid=
mysql error: You have an error in your SQL syntax near '' at line 1

mysql error number: 1064

Date: Sunday 14th of April 2002 08:48:49 PM
Script: http://www.bobcosta.com/bcportal/vbb/bcportal/vbb/postings.php
Referer: http://www.bobcosta.com/bcportal/vbb/postings.php?action=editthread&threadid=16

I am guessing that this is some sort of database inconsistency that was not expected by the VB program. Can someone verify this, or is it some other problem?

If I am correct, IMHO it is a lousy design that causes fatal crashes when the progarm encounters non-fatal dtabase inconsistencies. So I guess I have three questions:

1. What are my chances of getting this fixed by jelSoft in a reasonable time frame?

2. What do I have to do to my thread insert routine to populate the searchindex? I am not sure that I want these "add-on" threads searchable. Then again, maybe I do. I sure would like the option.

3. Are there any other "gotchas" I am headed for that anyone can warn me about?

Admin
04-16-2002, 10:01 AM
This is not a "lousy design", since your hacking caused this error. Blaming this on Jelsoft is the last thing you can do about it.

The program expects the thread to be populated with posts, like all threads are (when you first create a thread, you will see in newthread.php that a post is created as well). When you have a post-less thread vBulletin can't get the postid of the first post, which causes that error.

And I also don't understand how 'open' is a "lousy variable name", the name suggests this field means "Is this thread open for new posts?", where 1 means "Yes, it is open" while 0 means "No, it is closed". I think it's a perfect name, don't you?

galt
04-16-2002, 11:36 AM
Ah, the rigors of design debates...

First off, your requirement to have a post for a thread seems fine, and I can certainly do that, I just need to figure out the timing within the system I am developing.

As far as designs being lousy, in the "delete" issue I am referring to code design, not system design. A program should NEVER crash IMHO when it gets unexpected data or encounters database inconsistencies. Parent-child relationships can get messed up for a variety of reasons in any database that does not enforce referential integrity. There is nearly always a better response than crashing, usually to ignore it and move on. But I will be happy to revisit this debate-issue when I have fixed MY hack-bug. Some inconsistencies SHOULD be fatal, I just do not think (based on my current understanding) that this should be one of them.

I support this conclusion by the fact that I was able to post replies to this thread, and it only crashed when I tried to change the thread title. Apparently, lack of any posts was not so disturbing to the system, just this particular piece of code. I might be wrong, some of my testing was pretty late at night.

As far as "open" being a bad variable name, open is a keyword in quite a few of the languages I have worked in. It could reasonably be co-opted as a keyword in PHP version 9. There may also come a day when someone rewrites vB (or just writes some extensions or objects for it) in a new (not PHP) language where open IS a keyword. Since it is buried in the database, this will require an unnecessary variance between the PHP database and the (new language) database. You can see where this might lead. if jelsoft is the one to do it, they could make the databases consistent but would have to do some (significant?) code changes to the existing system. And this database change cascades into hacks and extensions written by other people.

Thanks firefly for the quick and clear response. Please don't take my comments as criticism, but more in the nature of good-hearted debate. As Jelsoft opens its system and more people incorporate it into other systems, you will no doubt encounter other opinions wiser than my own.