Content Ratings

Content Ratings [Paid] 2.8.1

No permission to buy ($35.00)
My (paid) Post Fiction add-on already allows per-thread allow/deny reactions (the allow parts is a little wonky).

But the entire restrictions UI? That is quite a bit more difficult on where the heck would you put it?
  • Allow/deny by user(s)
  • Allow/deny by thread ids
should be enough for a front-end mod ease.
 
Can this be linked with the reputation system?

Basically, I need an addon that I can add that allows users to select a reaction, for example, 1 through 5 stars. Then it give the receiving user reputation points. Could this be used along with the regular reactions? Could I use regular reactions for one thing and then this for ratings?
 
This add-on doesn't let more than 1 reaction be added the content. The "rating" is just leftover language from when reactions where likes without a type added to them.
 
been getting this lately
Code:
XF\Db\DeadlockException: MySQL query error [1213]: Deadlock found when trying to get lock; try restarting transaction src/XF/Db/AbstractStatement.php:230
Generated by: x Dec 21, 2023 at 8:08 PM
Stack trace
                    UPDATE xf_user
                    SET sv_sent_reactions = ?
                    WHERE user_id = ?
                
------------

#0 src/XF/Db/Mysqli/Statement.php(198): XF\Db\AbstractStatement->getException('MySQL query err...', 1213, '40001')
#1 src/XF/Db/Mysqli/Statement.php(79): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1213, '40001')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/addons/SV/ContentRatings/XF/Repository/Reaction.php(811): XF\Db\AbstractAdapter->query('
              ...', Array)
#4 src/addons/SV/ContentRatings/XF/Entity/ReactionContent.php(108): SV\ContentRatings\XF\Repository\Reaction->svUpdateUserReactions(49620, Array, true)
#5 src/XF/Entity/ReactionContent.php(117): SV\ContentRatings\XF\Entity\ReactionContent->adjustUserReactionScore(15278, 0)
#6 src/addons/SV/ContentRatings/XF/Entity/ReactionContent.php(180): XF\Entity\ReactionContent->_postSave()
#7 src/XF/Mvc/Entity/Entity.php(1277): SV\ContentRatings\XF\Entity\ReactionContent->_postSave()
#8 src/XF/Repository/Reaction.php(191): XF\Mvc\Entity\Entity->save()
#9 src/addons/SV/ContentRatings/XF/Repository/Reaction.php(1006): XF\Repository\Reaction->insertReaction(1, 'post', 5499747, Object(SV\SearchImprovements\XF\Entity\User), true, false)
#10 src/XF/Repository/Reaction.php(144): SV\ContentRatings\XF\Repository\Reaction->insertReaction(1, 'post', 5499747, Object(SV\SearchImprovements\XF\Entity\User), true, false)
#11 src/XF/ControllerPlugin/Reaction.php(67): XF\Repository\Reaction->reactToContent(1, 'post', 5499747, Object(SV\SearchImprovements\XF\Entity\User), true)
#12 src/XF/ControllerPlugin/Reaction.php(21): XF\ControllerPlugin\Reaction->actionToggleReaction(Object(SV\WarningImprovements\XF\Entity\Post), 'posts/reactions', 'posts')
#13 src/XF/ControllerPlugin/Reaction.php(14): XF\ControllerPlugin\Reaction->actionReact(Object(SV\WarningImprovements\XF\Entity\Post), 'posts', 'posts/react', 'posts/reactions')
#14 src/XF/Pub/Controller/Post.php(381): XF\ControllerPlugin\Reaction->actionReactSimple(Object(SV\WarningImprovements\XF\Entity\Post), 'posts')
#15 src/addons/KL/EditorManager/XF/Pub/Controller/Post.php(30): XF\Pub\Controller\Post->actionReact(Object(XF\Mvc\ParameterBag))
#16 src/XF/Mvc/Dispatcher.php(352): KL\EditorManager\XF\Pub\Controller\Post->actionReact(Object(XF\Mvc\ParameterBag))
#17 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Post', 'React', Object(XF\Mvc\RouteMatch), Object(X0815\InfoTo\XF\Pub\Controller\Post), NULL)
#18 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(X0815\InfoTo\XF\Pub\Controller\Post), NULL)
#19 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#20 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#21 src/XF.php(524): XF\App->run()
#22 index.php(20): XF::runApp('XF\\Pub\\App')
#23 {main}
 
There is a code-path which performs better but requires the json functions added in later mysql/mariadb versions.

I think there is one tweak I can do for the older mysql code path which may help. Can you open a ticket on my site so I can share a test build?
 
Hi, thanks for the great addon.
I have a small issue where I've run the importer to bring over my reactions from Post Ratings in 1.5 but the default reactions that came with the addon have now been removed and replaced with the old reactions and no icons. I was under the impression that this imported the old types to the new ones.

For example, I previously had a thank button and was hoping that it would be mapped to the new Love rating.

Have I messed something up? How can I get the icons back?
 
How does this work? Where can the log be found?

Log reaction deletion when the deletion user is not the reaction user
 
Hi, thanks for the great addon.
I have a small issue where I've run the importer to bring over my reactions from Post Ratings in 1.5 but the default reactions that came with the addon have now been removed and replaced with the old reactions and no icons. I was under the impression that this imported the old types to the new ones.

For example, I previously had a thank button and was hoping that it would be mapped to the new Love rating.

Have I messed something up? How can I get the icons back?
The importer migrates the old Post Ratings reactions wholesale, which includes the definitions. You might need to edit and then save a reaction to force a cache refresh which should fix the icons not showing. Otherwise you'll need to check the paths to verify they point to valid files still.

Re-adding the stock XF2 reactions can be done, but it is fairly fiddly. Please open a ticket on my site so I can assist.

How does this work? Where can the log be found?

Log reaction deletion when the deletion user is not the reaction user
It populates the moderator log. It doesn't populate the thread moderator action list for various annoying reasons
 
I went over this a few times before I came back to something potentially off with this addon. I'm on v2.5.3. With Content Ratings disabled, here is the behavior of the XF 2.2 code (which is expected):

1. Soft delete a resource that has 2 reactions (resourcehidden)
2. User's reaction_score is decreased by 2
3. Undelete the resource (resourcemadevisible)
4. User's reaction_score is increased by 2

With Content Ratings enabled, this is the behavior:

1. Soft delete a resource that has 2 reactions
2. User's reaction_score doesn't change
3. Undelete the resource
4. User's reaction_score is increased by an additional 2 reaction points
5. Repeating this process will increase the reaction_score by 2 additional each time

Here is an example query from the XF parent method fastUpdateReactionIsCounted:
UPDATE xf_user SET reaction_score = reaction_score {-} 3 WHERE user_id = 29

And here is the query from svUpdateUserReactions given the same arguments in the method call:

UPDATE xf_user SET reaction_score = reaction_score + 3, {sv_reactions} = JSON_SET(coalesce({sv_reactions}, ''), '$.1', greatest(0, coalesce(JSON_VALUE(coalesce(sv_reactions, '{}'), '$.1'), 0) - 3)) WHERE user_id = 29

It looks like the + operator is hard coded into this query, which means it will always add reaction score points regardless of the value of $add or $operator from the method:

Code:
public function svUpdateUserReactions($userId, $reactionIds, $add, $score = null)

//...

$operator = $add ? '+' : '-';

//...

$db->query("
                    UPDATE xf_user
                    SET reaction_score = reaction_score + ?,
                        {$jsonDoc} = JSON_SET(coalesce({$jsonDoc}, '{}'), {$sql} )
                    WHERE user_id = ?
                ", [$score, $userId]);

Did you possibly mean to include the operator in the query, because I tried this and it works as expected:
Code:
$db->query("UPDATE xf_user
    SET reaction_score = reaction_score {$operator} ?,
    {$jsonDoc} = JSON_SET(coalesce({$jsonDoc}, '{}'), {$sql})
    WHERE user_id = ?
", [$score, $userId]);

Note: I also had to remove the "false" argument from the recalculateReactionIsCounted method call in resourceHidden from the resourceItem entity.
 
Last edited:
Here is an example query from the XF parent method fastUpdateReactionIsCounted:
UPDATE xf_user SET reaction_score = reaction_score {-} 3 WHERE user_id = 29

And here is the query from svUpdateUserReactions given the same arguments in the method call:

UPDATE xf_user SET reaction_score = reaction_score + 3, {sv_reactions} = JSON_SET(coalesce({sv_reactions}, ''), '$.1', greatest(0, coalesce(JSON_VALUE(coalesce(sv_reactions, '{}'), '$.1'), 0) - 3)) WHERE user_id = 29

It looks like the + operator is hard coded into this query, which means it will always add reaction score points regardless of the value of $add or $operator from the method:
The operator isn't actually used in every case as the $score may be a negative value. But this likely needs some fixing since it is confusing and I think there is some confusion somewhere causing this. it will take a bit of tracing to verify this doesn't break things :(
 
I tried uninstalling v. 2.5.3 and ran into trouble when rebuilding the reaction cache for albums I think. Reinstalling solved the problem. Do you have any suggestions:
Code:
Fatal error: Trait "SV\ContentRatings\Stats\Ratable" not found in /home/*****/public_html/forum/src/addons/SV/ContentRatingsXFMG/XFMG/Stats/Album.php on line 10
 
@Xon Could you include a new criteria that was "exclude first post". I wanted to differentiate the reactions of the thread author from the replies.

Thank you :)

1712152265425.webp
 
Back
Top Bottom