Neler yeni

Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

  • Forumdan daha fazla yararlanmak için, profilinizi telefon numaranız 📱 ile doğrulayın ve daha ayrıcalıklı olun 😉
    Daha fazla bilgi!

How to easily convert utf8 tables to utf8mb4

masterdex

Aktif kullanıcı
Kullanıcı
Katılım
26 Mar 2017
Mesajlar
44
How to easily convert utf8 tables to utf8mb4 xenforo 2.
how did you make for your forum : xenforo.gen.tr

For each database:

ALTER DATABASE
database_name
CHARACTER SET = utf8mb4
COLLATE = utf8mb4_unicode_ci;


For each table:



ALTER TABLE
table_name
CONVERT TO CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;


For each column:



ALTER TABLE
table_name
CHANGE column_name column_name
VARCHAR(191)
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;


@eTiKeT™
 
Am I right?
You have XF1 community and you want to upgrade XF2 with utf8mb4.

I'll just advise you not to do it. But if you want! You can follow this steps,

MySQL only recently as of MySQL 5.5 now supports the full UTF-8 encoding set via the table coolation type utf8mb4.

If your SQL version is compatible with the utf8mb4 charset, here are the steps to follow to update your board:

1. Backup your Database and perform a test at first on a local installation
2. #SQL# Alter your SQL tables collation ; you can use the "utf8mb4_general_ci"
If you only want to make a small test for posts, you will also have to alter any related tables ; ie:

Kod:
ALTER TABLE xf_post CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE xf_search_index CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci

3. #PHP# Edit the class "XenForo_Application"
Search for:
Kod:
'charset' => 'utf8'

Replace with:

Kod:
'charset' => 'utf8mb4'

4. #PHP# Edit the class "XenForo_Input"
You will have to implement a characters conversion table in the function "cleanString" to safely bypass the below regex (ref):

Kod:
$string = preg_replace('/[\xF0-\xF7].../', '', $string);

here's an helper ready to use. So to implement in the "cleanString" function, just proceed this way:

Kod:
  public static function cleanString($string)
   {
     //Init the UTF8MB4 helper
     $extraHanzi = new Sedo_ExtraHanzi_Helper_Characters();
     //Encode characters using their unicode to bypass the safety regex
     $string = $extraHanzi->encodeExtraHanzi($string);
    
     // only cover the BMP as MySQL only supports that
     $string = preg_replace('/[\xF0-\xF7].../', '', $string);

     //Get back characters under their original form
     $string = $extraHanzi->decodeExtraHanzi($string);     

     return strtr(strval($string), self::$_strClean);
   }


And also look at this : How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
 

Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.