Add-on rebuildThreadPostPositions

Robert9

Well-known member
rebuildThreadPostPositions =>

UPDATE xf_post
SET position = (@position := IF(message_state = 'visible', @position + 1, GREATEST(@position, 0)))
WHERE thread_id = ?
ORDER BY post_date

I have three posts in thread 59000

post_idpost_dateposition after use of an changepostdate-addonposition should be
330884157152960002
330885153998858910
3308861540075914
2
1
If i use the addon with something like:



$threadRepo->rebuildThreadPostPositions($threadId);

i got 0,1, 2 for position like you can see above, so the sort is not done how i await it.

May someone has a hint why this sort is not done like i await it
=> ORDER BY post_date
 
Last edited:
Next step was to change the position by hand like it should be. After running
$threadRepo->rebuildThreadPostPositions($threadId);
the position field is again in a wrong like sorted by post_id.
 
Ok. In my next step i tried this:

//$threadRepo->rebuildThreadPostPositions($threadId);

$db = $this->db();
$db->query('SET @position := -1');
$db->query("
UPDATE xf_post
SET position = (@position := IF(message_state = 'visible', @position + 1, GREATEST(@position, 0)))
WHERE thread_id = ?
ORDER BY post_date
", $threadId);


Now i got the result that should be.
That means that somewhere in my xf there is a function with a hook right here that recalc my values in a wrong way?

 
No. Three different add-ons had the same problem. And finally i have forgotten this famous rule (for me, maybe not for you!)
Whenever you have a problem in your board, deactivate the add-ons from themehouse first to see if this helps.
Without the comment add-on from th everything is nice and work like it should. So all three add-ons to change the date/time of a post work now.
 
Last edited:
No. Three different add-ons had the same problem. And finally i have forgotten this famous rule (for me, maybe not for you!)
Whenever you have a problem in your board, deactivate the add-ons from themehouse first to see if this helps.
Without the comment add-on from th everything is nice and work like it should. So all three add-ons to change the date/time of a post work now.
As @ozzy47 suggested above, if the problem is the "comment add-on from th", why aren't you working with them to resolve it?

Also, why do you need three add-ons to change the date and time of a post? Surely one would do this.
 
  • rebuildThreadPostPositions was not working, this was the problem to solve tonight. Nothing else.
  • To have all needed functions here, we have to use at least two of the change date/author add-ons. To find out what fits best, we had installed four add-ons, two are deinstalled now. In a next step we have to change them for our needs.
 
Everything ok! Thank you.
There is a function in XF to recalc the position of posts in a thread by post_date.
This function was not working, because of another add-on. I have deinstalled this add-on.
My XF works now like it should.
 
Back
Top Bottom