• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Moving 'topics' via SQL command messes up indexing

#1
Hi,

I had been moving topics to different forums categories and I noticed the "last post" info doesn't update on it's own like how it normally would if I did it from the actual forum.
Also, if I don't 'rebuild' the post content from the ACP, everything seems to be totally out of place. URLs doesn't bring you to the right post and members' profile page "Postings" would also be incorrect.

I already rebuild the topics and everything is back to normal, but it took about 3-4 hours to complete and was very resource intensive. And I do keep planning on using SQL queries to move other topics, but I was hoping somneone could show me how I could rebuild that single topic that being moved also using SQL queries (as how the built-in tool would normally work for moving topics).

I hope i'm explaining myself correctly.

Thanks in advance!
 
#3
Hi Brogan,

I use keywords to find misplaced topics and move them to the correct section of the forum. This saves hours or even days of work. This is why I'm seeking for the SQL command to do how the forum's built-in tools would normal execute it.
 
#5
Code:
UPDATE xf_thread SET node_id =1 WHERE node_id !=5 && node_id !=6 && (title LIKE '%ABC%' OR title LIKE '%XYZ%');
I was hoping someone who was familiar with XF would show me the SQL query that would rebuilds only the affected topics after the above query is ran.
 
#6
I don't know if this is appropriate, but I can donate $25 to anyone who can help me with this with PayPal or AlertPay.
 

digitalpoint

Well-known member
#8
You really would be better off spinning them through the thread datawriter... that way you don't need to worry about backend stuff that happens (for example indexing).

A direct query like you are doing may be easier in the short-term, in the long term it's just going to cause problems (like you see with search indexes)... Some other things I can think of that might be managed internally when moving a thread to a different node... Like maybe something happens with thread subscriptions if a thread is moved to somewhere that the subscribed user can't access it anymore (a node they don't have permission to).

Let the datawriters handle the dirty work... that's what they are there for.
PHP:
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$writer->setExistingData($thread);
$writer->set('node_id', $newNodeId);
$writer->save();
 

Jeremy

Well-known member
#10
To be honest, I'm not even sure what i'm looking at. :unsure:

How would I go about this?
What digitalpoint is suggesting is that you take and write a cron job that'll preform the queries to find them IDs to move and then run proper functions to move the thread, so anything that happens behind the scenes happens behind the scenes.