Advanced Reputation System [Paid] [Deleted]

Status
Not open for further replies.
Also now getting some members saying that threads that they are watching are not showing in their watched thread list. They say that they can go into a thread they are watching and it will give them the option to unwatch but when they visit the watched thread list, the thread is not there. I disabled the reputation addon and asked them if the missing thread appeared in their list and they confirmed that it was back to normal.

Something strange is definitely going on with the reputation.
 
That sounds very much like a permissions issue actually.

If you disable Reputation and find one of these threads that disappears get its URL and then enable reputation then go to that URL. What's the error?
 
That sounds very much like a permissions issue actually.

If you disable Reputation and find one of these threads that disappears get its URL and then enable reputation then go to that URL. What's the error?

The actual thread doesn't disappear, it just no longer shows up in the watched threads list. Members are able to enter the thread with reputation enabled and even click watch/unwatch but that action has no outcome in their watched threads. They aren't reporting any error messages.
 
i cant see the "Add Reputation" link after installing.

all template modifications are applied, permissions set, but it doesnt want to appear.
i also dont see any reference to it in your code.

(like you have borbole_comment_post_link in your Post Comment addon, but here you dont have a borbole_reputation_post_link)
if i add a reference via the xenhelper
Code:
{xen:link 'posts/reputation-add', $post}
it tells me, that your controller doesnt define the action.

any idea how to get the link to actually GIVE reputation? :D
 
i cant see the "Add Reputation" link after installing.

all template modifications are applied, permissions set, but it doesnt want to appear.
i also dont see any reference to it in your code.

(like you have borbole_comment_post_link in your Post Comment addon, but here you dont have a borbole_reputation_post_link)
if i add a reference via the xenhelper
Code:
{xen:link 'posts/reputation-add', $post}
it tells me, that your controller doesnt define the action.

any idea how to get the link to actually GIVE reputation? :D

Try to change the execution order of the post template to 5 in the TMS. I have set it to 10 for both my mods and that is why you have this issue. Or you can pm me your email and I will email the xml file with the execution order changed.
 
Try to change the execution order of the post template to 5 in the TMS. I have set it to 10 for both my mods and that is why you have this issue. Or you can pm me your email and I will email the xml file with the execution order changed.

i dont have the post template modification.

attached a screenshot.
(member_card is deactivated as i manually merged it)
rep.webp

//edit to avoid confusion
i fixed post comments already, only problem is, that it isnt displaying a "Add Reputation" link.
rep1.webp
 
i dont have the post template modification.

attached a screenshot.
(member_card is deactivated as i manually merged it)
View attachment 60253

//edit to avoid confusion
i fixed post comments already, only problem is, that it isnt displaying a "Add Reputation" link.

You are missing the post one. Try to upgrade the mod's .xml file.
 

Attachments

  • repsystem.webp
    repsystem.webp
    6 KB · Views: 11
Hi @borbole,

There is a small bug in the additional check you make in the canViewThread forum in the extended Thread model.

It has the potential to incorrectly prevent alerts from being received and from threads appearing in some locations such as the Watch Threads list.

The issue lies in the reputation_count column that is in both the xf_thread table and xf_forum table.

If a $thread record is passed to the second parameter (which is $forum), then the reputation count from the thread record overwrites that of the forum record. It's valid to sometimes pass the $thread record as the $forum parameter if the $thread record has been fetched and joined to the xf_forum table. And one such place this occurs appears to be in the alert handler for posts.

The recommended fix is to have distinct column names for the reputation count in the xf_forum table and the xf_thread table. That way, they will never clash, and when you check for $forum['forum_reputation_count'] you can be sure it isn't really checking the $thread reputation count.
 
Hi @borbole,

There is a small bug in the additional check you make in the canViewThread forum in the extended Thread model.

It has the potential to incorrectly prevent alerts from being received and from threads appearing in some locations such as the Watch Threads list.

The issue lies in the reputation_count column that is in both the xf_thread table and xf_forum table.

If a $thread record is passed to the second parameter (which is $forum), then the reputation count from the thread record overwrites that of the forum record. It's valid to sometimes pass the $thread record as the $forum parameter if the $thread record has been fetched and joined to the xf_forum table. And one such place this occurs appears to be in the alert handler for posts.

The recommended fix is to have distinct column names for the reputation count in the xf_forum table and the xf_thread table. That way, they will never clash, and when you check for $forum['forum_reputation_count'] you can be sure it isn't really checking the $thread reputation count.

Hi Chris,

My mod does not add a reputation_count field in the thread table. It adds that field only in the forum and the user tables.
 
You're right.

But the issue still exists in exactly the same scenario.

You need to distinctly call the tables, user_reputation count and forum_reputation_count.

When an array of data contains user data and forum data and the reputation_count value is present from both tables then one overwrites the other... consider this:

So let's say the query is:

Code:
SELECT thread.*, forum.*, user.*
FROM xf_thread AS thread
INNER JOIN xf_user AS user ON
    (user.user_id = thread.user_id)
INNER JOIN xf_forum AS forum ON
    (thread.node_id = forum.node_id)
WHERE thread.thread_id = 1

As the xf_user table contains a reputation_count column and so does the xf_forum table, one value overwrites the other.

So distinctly naming them will resolve the issue.
 
Correct... into a PHP array. PHP array keys have to be unique. If they aren't, they overwrite each other.

Try it:
PHP:
Zend_Debug::dump(array('reputation_count' => 1, 'reputation_count' => 2));
 
The code speaks for itself.

Look at my example function below. It's not entirely realistic data, of course. But it's a good example to demonstrate what's happening. I've added some comments to your actual function too.

PHP:
<?php

//######################## Reputation System By Borbole ###########################
class Borbole_Reputation_Model_Thread extends XFCP_Borbole_Reputation_Model_Thread
{
    public function example()
    {
        $thread = array(
            'thread_id' => 1,
            'node_id' => 1,
            'user_id' => 1,
            'reputation_count' => 0, // This comes from the xf_forum columm shown for example only
            'reputation_count' => 2 // This comes from the xf_user column. This becomes the only reputation_count field set in the array.
        );

        $forum = array(
            'thread_id' => 1,
            'node_id' => 1,
            'user_id' => 1,
            'reputation_count' => 0, // This comes from the xf_forum columm shown for example only
            'reputation_count' => 2 // This comes from the xf_user column. This becomes the only reputation_count field set in the array.
        );

        $canViewThread = $this->canViewThread($thread, $forum);

        Zend_Debug::dump($canViewThread); // returns false;
    }

    public function canViewThread(array $thread, array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
    {
        $visitor = XenForo_Visitor::getInstance();

        // reputation_count isset in the $forum array and the value is 2.
        if(isset($forum['reputation_count']) AND $forum['reputation_count'] != 0)
        {
            // $visitor reputation_count is 2. $forum reputation_count is 2.
            if($visitor['reputation_count'] <= $forum['reputation_count'] AND !XenForo_Visitor::getInstance()->hasPermission('reputation', 'exlude_forum_rep'))
            {
                $errorPhraseKey = array('num_rep_forum', 'username' => $visitor['username'],
                    'repforum' => $forum['reputation_count'],
                    'repcount' => $visitor['reputation_count']
                );
                return false;
            }
        }
        return parent::canViewThread($thread, $forum, $errorPhraseKey, $nodePermissions, $viewingUser);
    }

}

If there were separate array keys for the user_reputation_count and forum_reputation_count:

PHP:
<?php

//######################## Reputation System By Borbole ###########################
class Borbole_Reputation_Model_Thread extends XFCP_Borbole_Reputation_Model_Thread
{
    public function example()
    {
        $thread = array(
            'thread_id' => 1,
            'node_id' => 1,
            'user_id' => 1,
            'forum_reputation_count' => 0,
            'user_reputation_count' => 2
        );

        $forum = array(
            'thread_id' => 1,
            'node_id' => 1,
            'user_id' => 1,
            'forum_reputation_count' => 0,
            'user_reputation_count' => 2
        );

        $canViewThread = $this->canViewThread($thread, $forum);

        Zend_Debug::dump($canViewThread); // returns true;
    }

    public function canViewThread(array $thread, array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
    {
        $visitor = XenForo_Visitor::getInstance();

        // reputation_count is set in the $forum array and the value is 0.
        // This condition evaluates false. Therefore parent is returned. parent returns true;
        if(isset($forum['forum_reputation_count']) AND $forum['forum_reputation_count'] != 0)
        {
            if($visitor['user_reputation_count'] <= $forum['forum_reputation_count'] AND !XenForo_Visitor::getInstance()->hasPermission('reputation', 'exlude_forum_rep'))
            {
                $errorPhraseKey = array('num_rep_forum', 'username' => $visitor['username'],
                    'repforum' => $forum['forum_reputation_count'],
                    'repcount' => $visitor['user_reputation_count']
                );
                return false;
            }
        }
        return parent::canViewThread($thread, $forum, $errorPhraseKey, $nodePermissions, $viewingUser);
    }

}

So, you see, the end result is different. One will return false (incorrect). One will return true (correct). And the result of it being incorrect means that whenever XenForo checks to see if a thread is viewable (this happens in many places), it has the potential to incorrectly deny access to that thread.
 
@borbole I'd appreciate it if you would give Chris's suggestion a try. It seems to make a lot of sense and so far you haven't been able to solve any of the problems I'm experiencing with this addon.

I'm still getting more than 50 server errors a minute that are attributed to your addon.

I'm still having users who no longer receive quote notifications.

I'm still having users who are having threads disappear from their watched list.

These problems go away 100% when your addon is disabled. They exist when every single addon on my site is disabled with the exception of yours.

You've asked me to install a fresh xenforo instance to test your addon. Considering these problems are occurring to random users on my site, I don't see how a brand new install with only a few test members would prove or disprove your theory that other addons (even disabled addons) are causing these problems. My production forum where these errors are occuring has nearly 12,500 users, which makes it a perfect place to test a problem that does not effect every single user.

I don't see the problem with giving the solution posted a try.
 
A clean install of XenForo and a clean install of the add-on will not make any difference to the example I pointed out above.
 
A clean install of XenForo and a clean install of the add-on will not make any difference to the example I pointed out above.

Ironically, commenting out this code fixes the problem.

Code:
if ($class == 'XenForo_Model_Thread')
        {
            $extend[] = 'Borbole_Reputation_Model_Thread';
        }

Must still be caused by another addon. :rolleyes:

Only remaining problem is a few server errors. Atleast I'm not getting 50 per minute like before.

Code:
Undefined index: node_id 
3 minutes ago - library/Borbole/Reputation/ControllerPublic/Thread.php:17
 
Well I'll leave you to it before I say something I regret.

Hey, do me a favour. Agree to this:

When you eventually find the bug and fix it, for the inconvenience you have caused @TeflonDon, please consider, as a gesture of goodwill, returning his €14.99. He has been and is being let down by an add-on developer he trusted. I think that would be more than appropriate when this bug is eventually fixed.
 
Also now getting some members saying that threads that they are watching are not showing in their watched thread list. They say that they can go into a thread they are watching and it will give them the option to unwatch but when they visit the watched thread list, the thread is not there. I disabled the reputation addon and asked them if the missing thread appeared in their list and they confirmed that it was back to normal.

Something strange is definitely going on with the reputation.

It works for me i don't have no problems
I can receive alerts from when someone quotes my threads or posts in a forum that i am watching
 
I can''t fix something that I can not reproduce. Like I said, I can not reproduce this for myself. Testing the mod in a brand new forum would tell you for sure if the mod is at fault or not. And further more, if there is anything wrong with the mod, how come that you are the only one that has this issue and no one else does not?

But I support my mods at their threads at your forum should you have any more questions regarding support.

I'm not sure why you can't reproduce it. @Chris Deeming was able to and was able to identify the section of the code that is causing the bug. Luckily for me, I don't use that feature at all so simply commenting out the lines that refer to it in the listener file eliminated the major problems being caused by the reputation addon.

I'm not a developer so unfortunately I don't understand exactly why the things that Chris mentioned only effects random users. I've made numerous test accounts on my board to try to recreate the problem for those specific users without any luck. Therefore, a clean install seems like a waste of time to me in regards to testing purposes. I also don't know why it only effects my board, that seems like a question that you should be answering rather than asking the end user.

Thank you for the addon, my users have used it 1,811 times already in the past few days since I installed it. I wish it worked a little cleaner but atleast now its not effecting core XenForo features. With that being said, I would have concerns about purchasing another addon from you especially after you charged me 10 euros for 2 lines of extra code and then showed less interest (or capability) in supporting your mod than another member on here did who had no stake in the matter at all.

It works for me i don't have no problems
I can receive alerts from when someone quotes my threads or posts in a forum that i am watching

No offense but you only have 11 members total out of the three forums in your signature. That just further proves my point that clean install with limited users is not going to prove that this bug doesn't exist.

Working correctly on a forum with 2 or 3 users and 1 thread does not mean the addon will work perfectly fine on a large production forum.
 
Status
Not open for further replies.
Top Bottom