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

marioman

Active member
#1
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';
 

marioman

Active member
#2
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
 

marioman

Active member
#4
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 ?
 
Top