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

My importer shows 0 items after

Discussion in 'XenForo Development Discussions' started by Kirk, Apr 12, 2015.

  1. Kirk

    Kirk Well-Known Member

    Hi all so I've created an importer to import usernotes. Currently the importer will import items but it shows a 0 items imported after i click the button. I've checked on my local wamp server and it shows the items actually imported even though the import button said 0 items imported.

    Here's my importer code

    PHP:
    <?php

    class ElUsernotes_Importer_vBulletin extends XFCP_ElUsernotes_Importer_vBulletin
    {


        public function 
    getSteps() {
            
    $steps parent::getSteps();

            
    $steps array_merge($steps,array(
                
    'usernotes' => array(
                    
    'title' => 'Import Usernotes',
                    
    'depends' => array('users')
                )
            ));

            return 
    $steps;
        }

        public function 
    stepUsernotes($start, array $options)
        {
            
    $options array_merge(array(
                
    'limit' => 200,
                
    'max' => false
            
    ), $options);

            
    $sDb $this->_sourceDb;
            
    $prefix $this->_prefix;

            
    /* @var $model XenForo_Model_Import */
            
    $model $this->_importModel;

            if (
    $options['max'] === false)
            {
                
    $options['max'] = $sDb->fetchOne('
                    SELECT MAX(usernoteid)
                    FROM ' 
    $prefix 'usernote
                '
    );
            }

            
    $vms $sDb->fetchAll($sDb->limit(
                
    '
                    SELECT usernote.*
                    FROM ' 
    $prefix 'usernote AS usernote
                    WHERE usernote.usernoteid > ' 
    $sDb->quote($start) . '
                    ORDER BY usernote.usernoteid
                '
    $options['limit']
            ));
            if (!
    $vms)
            {
                return 
    true;
            }

            
    $next 0;
            
    $total 0;

            
    $userIds = array();
            foreach (
    $vms AS $vm)
            {
                
    $userIds[] = $vm['userid'];
                
    $userIds[] = $vm['posterid'];
            }
            
    $userIdMap $model->getImportContentMap('user'$userIds);

            
    XenForo_Db::beginTransaction();

            
    $formatter XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text');
            
    $parser = new XenForo_BbCode_Parser($formatter);

            foreach (
    $vms AS $vm)
            {
                
    $next $vm['usernoteid'];

                
    $profileUserId $this->_mapLookUp($userIdMap$vm['userid']);
                if (!
    $profileUserId)
                {
                    continue;
                }

                
    $postUserId $this->_mapLookUp($userIdMap$vm['posterid'], 0);

                
    $info = array(
                    
    'profile_user_id'   =>  $profileUserId,
                    
    'user_id' =>  $postUserId,
                    
    'message'   =>  $parser->render($this->_convertToUtf8($vm['message'])),
                    
    'post_date' =>  $vm['dateline']
                );



                
    $vm $this->_importModel->importUserNote($next$info);
                if (
    $vm){
                    
    $total++;
                }
            }

            
    XenForo_Db::commit();
            
    $this->_session->incrementStepImportTotal($total);
            return array(
    $next$options$this->_getProgressOutput($next$options['max']));
        }

        public function 
    importUserNote($oldId$info)
        {
            
    $profilePostId $this->_importData($oldId'ElUsernotes_DataWriter_DiscussionMessage_Usernote''userNote''note_id'$info);
            if (
    $profilePostId) {
                return 
    $profilePostId;
            }
        }
    }
     
  2. Kirk

    Kirk Well-Known Member

    bump.
     
  3. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    A wild guess: these lines might be the culprit:
    PHP:
    $vm $this->_importModel->importUserNote($next$info);
    if (
    $vm){
        
    $total++;
    }
     
  4. Kirk

    Kirk Well-Known Member

    What should that be then?

    edit: tried commenting that out and it stills shows 0 items imported.
     
  5. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    umm... I have no idea... Maybe remove the conditional and see what happens? :p
     
  6. Kirk

    Kirk Well-Known Member

Share This Page