Fixed Remove Likes Option Broke DataWriter.php

After using the "Remove Likes" button on a members profile for a test, this happened.. and now everytime i try to do anything i'm met with this error?

An exception occurred: The existing data required by the data writer could not be found. in /var/www/html/library/XenForo/DataWriter.php on line 1345

  1. XenForo_DataWriter->_haveErrorsPreventSave() in XenForo/DataWriter.php at line 1387
  2. XenForo_DataWriter->save() in XenForo/LikeHandler/ProfilePost.php at line 20
  3. XenForo_LikeHandler_ProfilePost->incrementLikeCounter() in XenForo/Model/Like.php at line 314
  4. XenForo_Model_Like->unlikeContent() in *******/Credits/Model/Like.php at line 135
  5. *******_Credits_Model_Like->unlikeContent() in XenForo/Deferred/UserRemoveLikes.php at line 44
  6. XenForo_Deferred_UserRemoveLikes->execute() in XenForo/Model/Deferred.php at line 256
  7. XenForo_Model_Deferred->runDeferred() in XenForo/Model/Deferred.php at line 390
  8. XenForo_Model_Deferred->_runInternal() in XenForo/Model/Deferred.php at line 335
  9. XenForo_Model_Deferred->run() in XenForo/ViewRenderer/Abstract.php at line 352
  10. XenForo_ViewRenderer_Abstract::hasManualDeferredToRun() in XenForo/ViewRenderer/HtmlAdmin.php at line 130
  11. XenForo_ViewRenderer_HtmlAdmin->renderContainer() in XenForo/FrontController.php at line 618
  12. XenForo_FrontController->renderView() in XenForo/FrontController.php at line 158
  13. XenForo_FrontController->run() in /var/www/html/admin.php at line 13
Screenshot of the page: http://prntscr.com/4lssbb

I'm really confused as to whats going on.. and where i'm usually capable of fixing it myself.. i really don't know what to do this time.. Does anyone know how i can fix this? Even if its something as simple as purging whatever it is thats locking it up?

Thanks everyone!
 
Also, this is the error with "enableListeners" set to false:
An exception occurred: The existing data required by the data writer could not be found. in /var/www/html/library/XenForo/DataWriter.php on line 1345

  1. XenForo_DataWriter->_haveErrorsPreventSave() in XenForo/DataWriter.php at line 1387
  2. XenForo_DataWriter->save() in XenForo/LikeHandler/ProfilePost.php at line 20
  3. XenForo_LikeHandler_ProfilePost->incrementLikeCounter() in XenForo/Model/Like.php at line 314
  4. XenForo_Model_Like->unlikeContent() in XenForo/Deferred/UserRemoveLikes.php at line 44
  5. XenForo_Deferred_UserRemoveLikes->execute() in XenForo/Model/Deferred.php at line 256
  6. XenForo_Model_Deferred->runDeferred() in XenForo/Model/Deferred.php at line 390
  7. XenForo_Model_Deferred->_runInternal() in XenForo/Model/Deferred.php at line 335
  8. XenForo_Model_Deferred->run() in XenForo/ViewRenderer/Abstract.php at line 352
  9. XenForo_ViewRenderer_Abstract::hasManualDeferredToRun() in XenForo/ViewRenderer/HtmlAdmin.php at line 130
  10. XenForo_ViewRenderer_HtmlAdmin->renderContainer() in XenForo/FrontController.php at line 618
  11. XenForo_FrontController->renderView() in XenForo/FrontController.php at line 158
  12. XenForo_FrontController->run() in /var/www/html/admin.php at line 13
 
I think what's happening here is the deferred task that is running to remove the likes is still queued, so when you otherwise trigger some other rebuild (e.g. disabling, enabling or uninstalling an add-on) the likes removal task is still trying to run. So you're in a bit of a loop.

I'd recommend locating the task in the xf_deferred table in the database and look for a task with an execute class of:

XenForo_Deferred_UserRemoveLikes (or more likely just UserRemoveLikes) and remove that row from the database

This query may do the trick:

Code:
DELETE FROM xf_deferred WHERE execute_class = 'UserRemoveLikes'

Once it is gone, the site should run as normal.

EDIT: Worth noting that the issue will still exist, but it will at least allow you to do "stuff" while investigating what may be causing the error. Probably it is orphaned content as per Mike's reply below.
 
It looks like there's an orphaned like there (like on a piece of content that doesn't exist).
 
I suppose the simplest fix is to chanbe library/XenForo?Deferred/UserRemoveLikes.php:
Code:
$likeModel->unlikeContent($like);
to:
Code:
try
            {
                $likeModel->unlikeContent($like);
            }
            catch (Exception $e) {}
 
I think what's happening here is the deferred task that is running to remove the likes is still queued, so when you otherwise trigger some other rebuild (e.g. disabling, enabling or uninstalling an add-on) the likes removal task is still trying to run. So you're in a bit of a loop.

I'd recommend locating the task in the xf_deferred table in the database and look for a task with an execute class of:

XenForo_Deferred_UserRemoveLikes (or more likely just UserRemoveLikes) and remove that row from the database

This query may do the trick:

Code:
DELETE FROM xf_deferred WHERE execute_class = 'UserRemoveLikes'

Once it is gone, the site should run as normal.

EDIT: Worth noting that the issue will still exist, but it will at least allow you to do "stuff" while investigating what may be causing the error. Probably it is orphaned content as per Mike's reply below.
That does seem to have fixed the problem, thankyou all for your help.

I suppose the simplest fix is to chanbe library/XenForo?Deferred/UserRemoveLikes.php:
Code:
$likeModel->unlikeContent($like);
to:
Code:
try
            {
                $likeModel->unlikeContent($like);
            }
            catch (Exception $e) {}
I've also done this just incase.
 
Top Bottom