Fixed ErrorException: [E_NOTICE] Trying to get property 'reaction_score' of non-object

BassMan

Well-known member
I can see there are some add-on names inside (@Siropu , @Xon ), but not sure why is this error after clicking the Like button in the post.

Code:
Server error log

    ErrorException: [E_NOTICE] Trying to get property 'reaction_score' of non-object src/XF/Entity/ReactionContent.php:148

    Generated by: ... 1. feb 2019 ob 12.19

Stack trace

#0 src/XF/Entity/ReactionContent.php(148): XF::handlePhpError(8, '[E_NOTICE] Tryi...', '/home/mladiuc/p...', 148, Array)
#1 src/XF/Mvc/Entity/Entity.php(1580): XF\Entity\ReactionContent->_postDelete()
#2 src/XF/Repository/Reaction.php(124): XF\Mvc\Entity\Entity->delete()
#3 src/XF/ControllerPlugin/Reaction.php(65): XF\Repository\Reaction->reactToContent(1, 'post', 28218, Object(XFRM\XF\Entity\User), true)
#4 src/XF/ControllerPlugin/Reaction.php(19): XF\ControllerPlugin\Reaction->actionToggleReaction(Object(Siropu\AdsManager\XF\Entity\Post), 'posts/reactions', 'posts')
#5 src/XF/ControllerPlugin/Reaction.php(12): XF\ControllerPlugin\Reaction->actionReact(Object(Siropu\AdsManager\XF\Entity\Post), 'posts', 'posts/react', 'posts/reactions')
#6 src/XF/Pub/Controller/Post.php(368): XF\ControllerPlugin\Reaction->actionReactSimple(Object(Siropu\AdsManager\XF\Entity\Post), 'posts')
#7 src/XF/Mvc/Dispatcher.php(321): XF\Pub\Controller\Post->actionReact(Object(XF\Mvc\ParameterBag))
#8 src/XF/Mvc/Dispatcher.php(248): XF\Mvc\Dispatcher->dispatchClass('XF:Post', 'React', Object(XF\Mvc\RouteMatch), Object(SV\MultiPrefix\XF\Pub\Controller\Post), NULL)
#9 src/XF/Mvc/Dispatcher.php(100): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\MultiPrefix\XF\Pub\Controller\Post), NULL)
#10 src/XF/Mvc/Dispatcher.php(50): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#11 src/XF/App.php(2177): XF\Mvc\Dispatcher->run()
#12 src/XF.php(390): XF\App->run()
#13 index.php(20): XF::runApp('XF\\Pub\\App')
#14 {main}
 
There is something we can adjust here, but this indicates that there was an existing reaction on that content, so the first step was to remove that reaction. However, the type of reaction that was selected wasn't valid. First step here is to figure out how that situation happened.

Have you deleted any reaction definitions in the control panel? If so, did this content have that reaction?

Alternatively, did you have any add-ons that handled reactions, particularly where they migrated to the 2.1 code? If so, perhaps those reaction definitions weren't migrated?
 
Have you deleted any reaction definitions in the control panel? If so, did this content have that reaction?
Alternatively, did you have any add-ons that handled reactions, particularly where they migrated to the 2.1 code? If so, perhaps those reaction definitions weren't migrated?
Hm, actually, I had Content Ratings from @Xon ,but I've deleted it before running upgrade to XF 2.1. The content (the post) I put Like on had no reaction before.
 
There definitely would've been a reaction there before. I'm not sure how our code handles it when there's a reaction in the database but it's not for a valid reaction "type" -- it may show now reaction.

I'm going to move this to bugs as we likely need to handle deletion reaction (types) more cleanly. This will potentially require us to remove those reactions from existing content, but to also handle this situation better.

Did you use any tools to migrate those ratings to the 2.1 reaction system?

Also, I can't reproduce it anymore...
You'd only get this error once (on a particular piece of content).
 
Aa I recall, there were 2 like reaction on my XF 2.0 forum (using Content Ratings add-on). Not sure why there were two of them. I've deleted one. But that add-on was uninstalled before I've run the upgrade to XF 2.1.

You'd only get this error once (on a particular piece of content).
Yes, for now.
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.1).

Change log:
When deleting a reaction definition, delete all reactions of that type to ensure correct and consistent behavior.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top Bottom