[OzzModz] Post Edit Approve

[OzzModz] Post Edit Approve 2.0.0

No permission to download
Would be great to see this with options to include forums (not exclude, since when you have a social group addon installed where forums can be created by the groups owner, you´ll have to check a hell of forums each and every day). From my perspective it would be insane to activate that in ALL forums even on a moderate active board and regarding the workload for your moderators you`ld have to wear veeeery fast sneakers, as things could escalate... quickly ;)
 
It is necessary to make exceptions.
After all, your users do not edit their messages every 5 minutes. But it is useful to disable this in the Gazebo.
 
It seems to me there is a problem with post.position;
when I use this add-on and edit some of the posts in a thread; i get:

XF\Db\Exception: MySQL query error [1264]: Out of range value for column 'position' at row 1 in src/XF/Db/AbstractStatement.php at line 230

I have deinstalled all other add-ons I could see in the list, but the error stays.
Also i have some posts with visible and post_position = 0;

I have recalced all post.positions and start from beginning, again i get posts with visible and position = 0

Try:

edit 1, 2, 4;
now you have them moderated.
Now edit #3 as the new #1
 
It seems to me that

$post->isFirstPost()

is not available here.

So we try to set message_state instead of discussion_state.
 
I set up a new clean forum and your add-on.
Your add-on works perfectly.
Means I have to find now this add-on not working together with your add-on.
 
I am still searching.
Somewhere in xenforo is

#5 src/XF/Entity/Post.php(765): XF\Mvc\Entity\Entity->fastUpdate('position', -1)

if position is 0, we cant minus one.

Code:
Find 'fastUpdate('position'' in 'C:\www\xencafe\src\XF\Entity\Post.php' (22.03.2023 23:05:44; 09.12.2022 06:00:00):
C:\www\xencafe\src\XF\Entity\Post.php(725):    $this->fastUpdate('position', $basePosition + 1);
C:\www\xencafe\src\XF\Entity\Post.php(765):    $this->fastUpdate('position', $basePosition - 1);
 
Now, I have deinstalled all add-ons in web1 (where I have the problems);
I have uploaded xenforo again.
I have recalculated all positions in my thread; are now 0,1,2 ...
When I manually increase position 0 from first post to 1. I get no error.
It seems to me that (i dont know why, when, how), that isFirstPost() is not always true;
then we edit the first post with position = 0 and get the error.

Solution?
Find a reason why firstPost is not always true?
Dont allow anything when position is 0?
Add something to xenforo itself, not to decrease position by one, when postion == 0?
 
Last edited:
post.jpg

When i edit now post 35; state=visible; position=0; i will get the error.


Code:
            if ($post->message_state != 'moderated' && !$visitor->hasNodePermission($thread->node_id, 'ozzmodz_pea_bypass'))
            {
                if ($post->isFirstPost())
                {
                    echo "FIRST POST";

                    $thread->set('discussion_state', 'moderated', ['forceSet'=>true]);
                    $thread->save();
                }
                else
                {
                    echo "NO FIRST POST";

                    $post->set('message_state', 'moderated', ['forceSet'=>true]);
                }
            }


Result in console = NO FIRST POST



Question: How is it possible that a first post has isFirstPost false?
 
Code:
    public function isFirstPost()
    {
...

        if ($this->post_id == $thread->first_post_id)
        {
            return true;
        }



Here is the problem. I dont know why, but:

Code:
            echo $thread->first_post_id . " | ";
            echo $post->post_id;


shows that edited post_id != $thread->first_post_id
 
As long you have no better solution or an answer why the last_post_ied is not changed always,
i use

if ($post->isFirstPost() || $post->position == 0)
 
I repeat it for myself:

I edit post1 => post1.status = moderated
now post2 is post1 (and thread should know that!)
If thread does not know that, we dont have isFirstPost(), while post2.post_id != thread.first_post_id
so we try to set a post to moderated where post.position = 0; then we get an error, while xf sets position -=1

The big question now: Why or when thread_first_post_id is not set?
 
As written: In a clean forum, no problems.
In a used forum and all other add-ons deleted, still problems.

I will try to recreate the problems in the clean forum.
Maybe I try xdebug later ...
 
I repeat it for myself:

I edit post1 => post1.status = moderated
now post2 is post1 (and thread should know that!)
If thread does not know that, we dont have isFirstPost(), while post2.post_id != thread.first_post_id
so we try to set a post to moderated where post.position = 0; then we get an error, while xf sets position -=1
Unable to reproduce this with ~600 active add-ons.

First of all, you need to find the add-on that is causing this problem, simply disabling related ones until the problem recurs.

Thread caches (including first_post_id) can be restored with "Rebuild threads" rebuild tool.
 
Top Bottom