Fixed Error When Permanently Deleting Threads

latimer

Active member
When attempting to permanently delete a thread using the delete link on the first post under 1.1.0 beta 1 I am getting an error. I've tried on different forum nodes, as well as on a clean install of the forum. At the top of the page before any of the html output it says
Code:
<div>fetch forum 2</div>
And this is the actual error text:
Code:
Undefined index: node_id

XenForo_Application::handlePhpError() in XenForo/DataWriter/Discussion/Thread.php at line 388
XenForo_DataWriter_Discussion_Thread::setForumCacheItem() in XenForo/DataWriter/DiscussionMessage/Post.php at line 145
XenForo_DataWriter_DiscussionMessage_Post->setExtraData() in XenForo/DataWriter/DiscussionMessage/Post.php at line 163
XenForo_DataWriter_DiscussionMessage_Post->_forumCountsMessages() in XenForo/DataWriter/DiscussionMessage/Post.php at line 131
XenForo_DataWriter_DiscussionMessage_Post->_updateUserMessageCount() in XenForo/DataWriter/DiscussionMessage.php at line 734
XenForo_DataWriter_DiscussionMessage->_postDelete() in XenForo/DataWriter.php at line 1716
XenForo_DataWriter->delete() in XenForo/Model/Post.php at line 1013
XenForo_Model_Post->deletePost() in XenForo/ControllerPublic/Post.php at line 251
XenForo_ControllerPublic_Post->actionDelete() in XenForo/FrontController.php at line 310
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
XenForo_FrontController->run() in /home/mango/public_html/index.php at line 13
 
You're deleting an post, not a thread!

PHP:
XenForo_Model_Post->deletePost() in XenForo/ControllerPublic/Post.php at line 251 XenForo_ControllerPublic_Post->actionDelete() in XenForo/FrontController.php at line 310
   
/************** */

/**
     * Deletes an existing post.
     *
     * @return XenForo_ControllerResponse_Abstract
     */
    public function actionDelete()

2. it seems that they've forgotten some debug code
PHP:
public static function getForumCacheItem($forumId)
    {
        if (!self::isForumCacheItem($forumId))
        {
            echo "<div>fetch forum $forumId</div>";
            self::setForumCacheItem(XenForo_Model::create('XenForo_Model_Forum')->getForumById($forumId));
        }

        return self::$forumCache[$forumId];
    }

but i'm sure that's not causing your bug
 
Sorry you're right. This is when a thread is deleted by using the delete button on the first post, not using the moderation overlay menu in the forum view.
 
Confirmed, when somebody tries to hard delete the first post you'll get the error
 
The problem is somewhere in
XenForo_DataWriter_DiscussionMessage_Post::_forumCountsMessages
PHP:
protected function _forumCountsMessages()
    {
        if (!$forum = $this->getExtraData(self::DATA_FORUM))
        {
            $forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumByThreadId($this->get('thread_id'));

I don't know why(because i didn't look:P) , but getForumByThreadId return ALWAYS a empty array as i tried it now...
that's why
PHP:
$this->setExtraData(self::DATA_FORUM, $forum);
sets the empty array and why node_id isn't found
 
Confirmed on a 1.1 beta 1 forum trying to delete the first post of a thread.
Using Thread tools -> delete thread works.
 
Top Bottom