fluxbb_to_flarum icon indicating copy to clipboard operation
fluxbb_to_flarum copied to clipboard

Error during the migration

Open haruka-7 opened this issue 7 years ago • 43 comments

Hello, During the ./run build, I have this error : ln: /usr/bin/php: File exists. I'm under Fedora and got the same on Ubuntu.

It's seems to be OK, after deleting the line && ln -s /usr/bin/php7 /usr/bin/php \ in the Dockerfile. But during the ./run init I have the error :

[INFO] Install migration script dependencies
Your requirements could not be resolved to an installable set of packages.
[INFO] Creation of the default TextFormatter bundle
PHP Warning:  require(vendor/autoload.php): failed to open stream: No such file or directory in /scripts/createCustomBundle.php on line 3
PHP Fatal error:  require(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/share/php7') in /scripts/createCustomBundle.php on line 3

haruka-7 avatar Nov 03 '18 01:11 haruka-7

Post the composer's output composer install --working-dir=/scripts (inside the container), please.

hardware avatar Nov 03 '18 07:11 hardware

Hi,

Thanks for your help. Docker is something new for me, sorry if I misunderstand something. I run composer install --working-dir=/scripts in flarum container with this output :

[RuntimeException]                                             
Invalid working directory specified, /scripts does not exist.

To do that I first run : sudo docker-compose up -d Then sudo docker exec -i -t flarum sh And composer install --working-dir=/scripts

haruka-7 avatar Nov 03 '18 09:11 haruka-7

I fixed the build error and php dependencies.

composer install --working-dir=/scripts

[INFO] Install migration script dependencies
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - intervention/image 2.4.2 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.

Can you retry ?

hardware avatar Nov 03 '18 10:11 hardware

Solved ! Thank you very much !

haruka-7 avatar Nov 03 '18 10:11 haruka-7

@P3ter can you give us a feedback of your migration?

al3xLvs avatar Nov 03 '18 11:11 al3xLvs

Yes of course. I try to migrate this forum : http://forum.pluxml.org. For the moment I have this error :

[03-Nov-2018 10:42:14 UTC] [INFO] ------------------- STARTING MIGRATION PROCESS -------------------
[03-Nov-2018 10:42:14 UTC] [INFO] Connected successfully to the databases !
[03-Nov-2018 10:42:14 UTC] [INFO] #############################
[03-Nov-2018 10:42:14 UTC] [INFO] ### [1/9] Users migration ###
[03-Nov-2018 10:42:14 UTC] [INFO] #############################
[03-Nov-2018 10:42:14 UTC] [INFO] Migrating 15864 users...
[03-Nov-2018 10:42:14 UTC] [WARN] User 'Invité' cleaned (incorrect format). New nickname : 'Invite'
[03-Nov-2018 10:42:15 UTC] [WARN] User '.matt' cleaned (incorrect format). New nickname : 'matt'
[03-Nov-2018 10:42:15 UTC] [WARN] User 'Beno@' cleaned (incorrect format). New nickname : 'Benoat'
[03-Nov-2018 10:42:15 UTC] [WARN] User 'w0k.' cleaned (incorrect format). New nickname : 'w0k'
[03-Nov-2018 10:42:15 UTC] [WARN] User '[Chris]' cleaned (incorrect format). New nickname : 'Chris'
[03-Nov-2018 10:42:15 UTC] [ERROR] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'chris' for key 'users_username_unique' in /scripts/function.php:44
Stack trace:
#0 /scripts/function.php(44): PDOStatement->execute(Array)
#1 /scripts/importer/users.php(103): RunPreparedQuery(Object(PDO), Array, 'INSERT INTO use...')
#2 /scripts/migrate.php(68): require('/scripts/import...')
#3 {main}

The username "[Chris]" is renamed "Chris", but a username "chris" already exist.

haruka-7 avatar Nov 04 '18 22:11 haruka-7

Je pense qu'on peut parler français. Content d'aider le staff de PluXml :)

Il faudrait ajouter une vérification à chaque fois que le script est obligé de renommer un pseudo, si il existe déjà, le script l'ignore et passe au suivant. Pour le forum de mondedie.fr, les doublons on a géré ça au cas par cas parce qu'il y en avait pas beaucoup.

hardware avatar Nov 04 '18 22:11 hardware

Merci à vous d'être si réactif :-)

La fonctionnalité que tu décris n'existe pas déjà ? Je pose la question car je viens d'avoir l'erreur : [ERROR] Unable to clean username 'dj stark91', try to fix this account manually. Proposed nickname : 'djstark91' (already exists in fluxbb database)

A priori j'ai aussi un problème de doublons d'adresse mail : [ERROR] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[email protected]' for key 'users_email_unique' in /scripts/function.php:44

haruka-7 avatar Nov 04 '18 22:11 haruka-7

Ah oui effectivement, j'avais oublié ça, faut dire que ça remonte à 2 ans.

Dans la requête SQL j'avais mis WHERE BINARY, donc la recherche est faite en prenant en compte la casse. Le script génère le pseudo Chris et dans la bdd de fluxbb c'est chris donc le check passe, par contre ensuite le base de donnée renvoie une violation de contrainte parce que son check interne lui n'est pas sensible à la casse.

J'ai retiré le mot clé BINARY de la requête pour qu'elle ne soit plus sensible à la casse, ça devrait être bon maintenant.

hardware avatar Nov 04 '18 23:11 hardware

Par contre pour l'adresse mail, il y a pas grand chose à faire, c'est forcément du multi compte donc là, à votre staff de voir ce que vous devez faire dans ce cas là.

hardware avatar Nov 04 '18 23:11 hardware

Je viens de tester ça semble fonctionner : [ERROR] Unable to clean username '[Chris]', try to fix this account manually. Proposed nickname : 'Chris' (already exists in fluxbb database)

En revanche, j'ai eu les messages ci-dessous (sans que ça bloque la migration) :


[WARN] User 'Сергiй' cleaned (incorrect format). New nickname : 'Sergiy'

Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in /scripts/vendor/s9e/text-formatter/src/Parser/BuiltInFilters.php on line 175

Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in /scripts/vendor/s9e/text-formatter/src/Parser/BuiltInFilters.php on line 175
[ERROR] Unable to clean username 'Valérian', try to fix this account manually. Proposed nickname : 'Valerian' (already exists in fluxbb database)

Pour les mails, si je supprime les lignes qui font l'INSERT dans la table pun_users, ça va poser problème pour la suite de la migration ?

haruka-7 avatar Nov 04 '18 23:11 haruka-7

Pour les messages idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated, c'est pas très grave, la version de la librairie s9e/text-formatter date d'août 2016, donc certaines choses ont été dépréciées dans PHP depuis.

Je te conseil d'ignorer ces messages, et lorsque la migration sera terminée et fonctionnelle, tu pourras tester avec la dernière version en modifiant le fichier composer.json.

https://github.com/mondediefr/fluxbb_to_flarum/blob/master/scripts/composer.json

Faudrait faire la même chose pour les autres librairies aussi.

https://github.com/s9e/TextFormatter https://github.com/Intervention/image https://github.com/illuminate/support https://github.com/cocur/slugify https://github.com/PHPMailer/PHPMailer

Pour les mails, si je supprimer les lignes qui font l'INSERT dans la table pun_users, ça va poser problème pour la suite de la migration ?

Non, je pense pas.

hardware avatar Nov 04 '18 23:11 hardware

Bonjour,

J'avance bien, mais pour info j'ai eu une nouvelle erreur :

[INFO] ###################################
[INFO] ### [5/9] User groups migration ###
[INFO] ###################################
[INFO] Migrating 4 user groups...
[INFO] + Group 'Administrateurs' done
[INFO] + Group 'Modérateurs' done
[ERROR] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name_singular' cannot be null in /scripts/function.php:44
Stack trace:
#0 /scripts/function.php(44): PDOStatement->execute(Array)
#1 /scripts/importer/groups.php(54): RunPreparedQuery(Object(PDO), Array, 'INSERT INTO gro...')
#2 /scripts/migrate.php(72): require('/scripts/import...')
#3 {main}
/!\ An error occurred while executing the prepared query% 

L'extrait concerné dans le dump fluxBB :

INSERT INTO `pun_groups` (`g_id`, `g_title`, `g_user_title`, `g_promote_min_posts`, `g_promote_next_group`, `g        _moderator`, `g_mod_edit_users`, `g_mod_rename_users`, `g_mod_change_passwords`, `g_mod_ban_users`, `g_read_bo        ard`, `g_view_users`, `g_post_replies`, `g_post_topics`, `g_edit_posts`, `g_delete_posts`, `g_delete_topics`,         `g_post_links`, `g_set_title`, `g_search`, `g_search_users`, `g_send_email`, `g_post_flood`, `g_search_flood`,         `g_email_flood`, `g_report_flood`) VALUES
(1, 'Administrateurs', 'Administrateur', 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0),
(2, 'Modérateurs', 'Pluxml Staff', 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0),
(3, 'Invités', NULL, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0),
(4, 'Membres', NULL, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 60, 30, 60, 60);

J'ai résolu le problème en remplaçant la valeur NULL par la valeur de l'ID. C'est peut-être quelque chose qui peut-être prévu par le script.

Suite à ça, le script de migration c'est entièrement terminée avec succès (en 10 min 29 sec).

haruka-7 avatar Nov 05 '18 21:11 haruka-7

Ok je vais tester ça ce weekend avec l'ancienne bdd de mondedie Je vais mettre tout ça à jour.

al3xLvs avatar Nov 05 '18 21:11 al3xLvs

Finalement j'ai peut-être toujours un soucis au niveau du remplacement des pseudos par le script, exemple : [ERROR] Unable to clean username 'Sébastien', try to fix this account manually. Proposed nickname : 'Sebastien' (already exists in fluxbb database) Après vérification je n'ai pas de "Sebastien" dans le dump, j'ai uniquement un "Sébastien". J'ai remarqué que j'avais le même problème sur tous les username qui comportent des accents (Régis, Stéphane, Gasbé, Aurélien, Gégé, etc).

haruka-7 avatar Nov 05 '18 21:11 haruka-7

voilà c'est pour ça que l'on avait mis BINARY dans la requête. Je vais réfléchir à une solution avec @hardware

al3xLvs avatar Nov 05 '18 22:11 al3xLvs

@P3ter peux-tu tester avec cette requête SELECT id FROM {$dbFluxbbPrefix}users WHERE username = :username collate utf8_bin ?

ici : https://github.com/mondediefr/fluxbb_to_flarum/blob/master/scripts/importer/users.php#L34

Si ça fonctionne pas, faut trouver un charset autre que utf8_bin qui est pas sensible à la casse mais qui est sensible aux accents lors des comparaisons.

hardware avatar Nov 05 '18 22:11 hardware

J'ai modifié la ligne ainsi :

$query = RunPreparedQuery($dbFluxbb, [':username' => $username], "SELECT id FROM {$dbFluxbbPrefix}users WHERE username = :username collate utf8_bin");

Et j'ai obtenu l'erreur :

[WARN] User '[Chris]' cleaned (incorrect format). New nickname : 'Chris'
[ERROR] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'chris' for key 'users_username_unique' in /scripts/function.php:44
Stack trace:
#0 /scripts/function.php(44): PDOStatement->execute(Array)
#1 /scripts/importer/users.php(103): RunPreparedQuery(Object(PDO), Array, 'INSERT INTO use...')
#2 /scripts/migrate.php(68): require('/scripts/import...')
#3 {main}

J'ai effectivement dans mon dump un user "[Chris]" et un autre user "chris", mais pas de user "Chris". En revanche ça corrige mon problème avec les accents dans les username !

haruka-7 avatar Nov 05 '18 23:11 haruka-7

Oui mais ça du coup c'est normal.

On est obligé de changer les pseudos puisqu'il faut qu'il soit compatible "url" si je peux me permettre. Donc on slugify les pseudos. https://github.com/mondediefr/fluxbb_to_flarum/blob/master/scripts/importer/users.php#L30-L33

Alors quand on a le user Chris et un autre user chris on est un peu bloqué. Comme le username doit être unique cf code flarum mysql n'accepte pas. Chris et chris pour lui c'est la même chose, donc on se retrouve avec cette erreur Integrity constraint violation: 1062 Duplicate entry 'chris' for key 'users_username_unique' J'ai pas de solution élégante sous la main, comme là dit plus haut @hardware nous sur notre forum on a géré ce problème au cas par cas. Mais pour un gros forum il faudrait sans doute trouver une solution...

al3xLvs avatar Nov 05 '18 23:11 al3xLvs

Ok je vais regarder pour traiter ces cas manuellement, merci pour votre aide. La petite nouveauté du jour : j'ai essayé de lancer une migration avec des avatars et j'ai obtenu l'erreur ci-dessous :

Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in /scripts/migrate.php on line 24
[INFO] ------------------- STARTING MIGRATION PROCESS -------------------
[INFO] Connected successfully to the databases !
[INFO] #############################
[INFO] ### [1/9] Users migration ###
[INFO] #############################
[INFO] Migrating 15820 users...
[WARN] User 'Invité' cleaned (incorrect format). New nickname : 'Invite'
[WARN] User '.matt' cleaned (incorrect format). New nickname : 'matt'

Fatal error: Uncaught BadMethodCallException: Method Illuminate\Support\Str::quickRandom does not exist. in /scripts/vendor/illuminate/support/Traits/Macroable.php:76
Stack trace:
#0 /scripts/importer/users.php(66): Illuminate\Support\Str::__callStatic('quickRandom', Array)
#1 /scripts/migrate.php(68): require('/scripts/import...')
#2 {main}
  thrown in /scripts/vendor/illuminate/support/Traits/Macroable.php on line 76

haruka-7 avatar Nov 07 '18 21:11 haruka-7

Pour les avatars ok je prend note, je fix ça bientôt.

al3xLvs avatar Nov 07 '18 21:11 al3xLvs

Hello, Je viens aux nouvelles au sujet de mon problème avec les avatars. Une idée d'où ça pourrait venir ?

haruka-7 avatar Nov 18 '18 09:11 haruka-7

Tu peux tester le dernier commit? https://github.com/mondediefr/fluxbb_to_flarum/commit/d41b78ab7e67f6d2ddfb0ce792ab258fe1da4439 Normalement ça devrait fonctionner.

al3xLvs avatar Nov 18 '18 14:11 al3xLvs

J'ai testé après avoir mis à jour master en local (j'ai bien le commit en question), mais j'ai obtenu l'erreur ci-dessous :

[INFO] ------------------- STARTING MIGRATION PROCESS -------------------
[INFO] Connected successfully to the databases !
[INFO] #############################
[INFO] ### [1/9] Users migration ###
[INFO] #############################
[INFO] Migrating 1756 users...
[WARN] User 'Invité' cleaned (incorrect format). New nickname : 'Invite'
[WARN] User '.matt' cleaned (incorrect format). New nickname : 'matt'

Fatal error: Uncaught Error: Call to undefined method Intervention\Image\Image::make() in /scripts/importer/users.php:68
Stack trace:
#0 /scripts/migrate.php(68): require()
#1 {main}
  thrown in /scripts/importer/users.php on line 68

haruka-7 avatar Nov 18 '18 18:11 haruka-7

@P3ter j'ai fait un fix, peux-tu tester? (docker ne fonctionne plus chez moi 😅 ) J'ai aussi fait un fix pour cette erreur ici Normalement il va juste ignorer chris, au lieu de faire planter le script.

ps: j'ai pas testé, j'ai juste poussé les changements sur la branch

al3xLvs avatar Nov 18 '18 20:11 al3xLvs

ahah :-)

[INFO] ------------------- STARTING MIGRATION PROCESS -------------------
[INFO] Connected successfully to the databases !
[INFO] #############################
[INFO] ### [1/9] Users migration ###
[INFO] #############################
[INFO] Migrating 1756 users...
[ERROR] PDOException: SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8_bin' is not valid for CHARACTER SET 'binary' in /scripts/function.php:43
Stack trace:
#0 /scripts/function.php(43): PDOStatement->execute(Array)
#1 /scripts/importer/users.php(37): RunPreparedQuery(Object(PDO), Array, 'SELECT id FROM ...')
#2 /scripts/migrate.php(68): require('/scripts/import...')
#3 {main}

haruka-7 avatar Nov 18 '18 21:11 haruka-7

Pareil c'est un fix que j'ai pas testé. edit: on va finir par réussir 😅

al3xLvs avatar Nov 18 '18 21:11 al3xLvs

;-)

[INFO] ------------------- STARTING MIGRATION PROCESS -------------------
[INFO] Connected successfully to the databases !
[INFO] #############################
[INFO] ### [1/9] Users migration ###
[INFO] #############################
[INFO] Migrating 1756 users...
[ERROR] PDOException: SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'binary' in /scripts/function.php:43
Stack trace:
#0 /scripts/function.php(43): PDOStatement->execute(Array)
#1 /scripts/importer/users.php(37): RunPreparedQuery(Object(PDO), Array, 'SELECT id FROM ...')
#2 /scripts/migrate.php(68): require('/scripts/import...')
#3 {main}

haruka-7 avatar Nov 18 '18 22:11 haruka-7

pourtant quand tu avais testé ça fonctionné cette requête sql non? ton message ici https://github.com/mondediefr/fluxbb_to_flarum/issues/4#issuecomment-436070066

t'avais mis ça dans le fichier user.php

$query = RunPreparedQuery($dbFluxbb, [':username' => $username], "SELECT id FROM {$dbFluxbbPrefix}users WHERE username = :username collate utf8_bin");

al3xLvs avatar Nov 18 '18 22:11 al3xLvs

Les fichiers sont à jour du reprository (branche master, sans aucune modification). J'ai ré-essayé avec cette requête mais ça ne passe plus...

haruka-7 avatar Nov 18 '18 22:11 haruka-7