1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Resource Category Change - Discussion Thread Vanishes

Discussion in 'Resource Manager Resolved Bugs' started by MattW, Mar 21, 2014.

  1. MattW

    MattW Well-Known Member

    OK, so to reproduce this.

    Create a category which doesn't have anything set for "Automatically Create Thread in Forum:"

    With a resource from a category which does have "Automatically Create Thread in Forum:" set, and a current discussion thread associated with it, edit the resource, and move it to the category with no "Automatically Create Thread in Forum:" set.

    The discussion thread vanishes, and if you look in xf_thread table, the node_id is set to 0

    Discovered this while testing @Bob B 's Showcase as his code uses the same as the RM

    code:

    PHP:
    if ($this->isUpdate() && $this->isChanged('resource_category_id') && $this->get('discussion_thread_id'))
            {
                
    $catDw $this->_getCategoryDwForUpdate();

                
    $nodeId $this->getOption(self::OPTION_CREATE_THREAD_NODE_ID);
                if (
    $nodeId === null)
                {
                    
    $nodeId $catDw->get('thread_node_id');
                }
                
    $prefixId $this->getOption(self::OPTION_CREATE_THREAD_PREFIX_ID);
                if (
    $prefixId === null)
                {
                    
    $prefixId $catDw->get('thread_prefix_id');
                }

                
    $threadDw XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread'XenForo_DataWriter::ERROR_SILENT);
                if (
    $threadDw->setExistingData($this->get('discussion_thread_id')) && $threadDw->get('discussion_type') == 'resource')
                {
                    
    $threadDw->set('node_id'$nodeId);
                    
    $threadDw->set('prefix_id'$prefixId);
                    
    $threadDw->save();
                }
            }
     
  2. Mike

    Mike XenForo Developer Staff Member

    It will now (soft) delete the thread if moved to a category that doesn't have an associated forum. (It will be restored if moved back.)
     
    MattW likes this.

Share This Page