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

XF 1.1 importer get content like that (???????)

Discussion in 'Installation, Upgrade, and Import Support' started by marioman, Nov 4, 2011.

  1. marioman

    marioman Active Member

    hi,

    i have vbulletin use charset utf-8 and have arabic contents
    when i begin importing xenforo get all arabic data like that ??????????
    i tested it twice first give (Force Character Set: ) charset utf-8
    second let it empty

    i have this in my vbulletin config
    PHP:
    $config['Mysqli']['charset'] = 'utf8';
     
  2. marioman

    marioman Active Member

    i think the problem in getting data from vbulletin database
    i make this change in importer/vbulletin.php
    PHP:
        public function validateConfiguration(array &$config)
        {
            
    $errors = array();
     
            
    $config['db']['prefix'] = preg_replace('/[^a-z0-9_]/i'''$config['db']['prefix']);
     
    $db Zend_Db::factory('mysqli',
                    array(
                        
    'host' => $config['db']['host'],
                        
    'port' => $config['db']['port'],
                        
    'username' => $config['db']['username'],
                        
    'password' => $config['db']['password'],
                        
    'dbname' => $config['db']['dbname'],
                        
    'charset' => ''
                    
    )
                );
                
    $db->getConnection();
               
                
    $user $db->fetchAll('
                    SELECT *
                    FROM ' 
    $config['db']['prefix'] . 'user
                    LIMIT 1
                '
    );
                
    print_r($user);
    }
    it print information about first user in vbulletin db
    username printed ?????????
    i tried to change charset to utf-8, windows-1252, cp1256
    i get same error
     
  3. marioman

    marioman Active Member

    when i use
    PHP:
    $db->query('SET CHARACTER SET utf8');
    before do any query it get correct data
     
  4. marioman

    marioman Active Member

    i solve it by adding this
    PHP:
    $this->_sourceDb->query('SET CHARACTER SET utf8');
    in _bootstrap function

    PHP:
    protected function _bootstrap(array $config)
        {
            if (
    $this->_sourceDb)
            {
                
    // already run
                
    return;
            }
     
            @
    set_time_limit(0);
     
            
    $this->_config $config;
     
            
    $this->_sourceDb Zend_Db::factory('mysqli',
                array(
                    
    'host' => $config['db']['host'],
                    
    'port' => $config['db']['port'],
                    
    'username' => $config['db']['username'],
                    
    'password' => $config['db']['password'],
                    
    'dbname' => $config['db']['dbname'],
                    
    'charset' => $config['db']['charset']
                )
            );
            
    $this->_sourceDb->query('SET CHARACTER SET utf8');
            
    $this->_prefix preg_replace('/[^a-z0-9_]/i'''$config['db']['prefix']);
     
            if (!empty(
    $config['charset']))
            {
                
    $this->_charset $config['charset'];
            }
        }
    working fine now, but what's your opinion ?
     
    alexD likes this.

Share This Page