Il y a 389 articles et 19 utilisateurs inscrits (ce bandeau est défini dans MediaWiki:Sitenotice)

Migration Pandor vers Drupal 9

De AJLSM
Aller à la navigation Aller à la recherche

La mise à jour a été effectuée avec les instructions disponibles ici : http://mw.ajlsm.com/wiki/Basculer_Drupal_8_vers_Drupal_9

Cette migration a été réalisée le 11/11/2020. Les instructions suivantes devront être vérifiées par rapport aux dates des sources à migrer.

Des compléments doivent être apportés dans la documentation initiale.

Le déroulé suivant ne documente pas les commandes utilisées.

Voir la documentation principale : http://mw.ajlsm.com/wiki/Basculer_Drupal_8_vers_Drupal_9.

Notice :
On utilise plusieurs fois les instructions, vider les caches et .update.php. Ces commandes sont lancées depuis $url_drupal_site/admin/config/development/performance et $url_drupal_site/update.php .

Apache 4.2.7 minimum requis

[modifier | modifier le wikicode]

Test version Apache

[modifier | modifier le wikicode]
$ apachectl -V

Réponse : 4.2.29

Ok

PHP 7.3 minimum requis

[modifier | modifier le wikicode]

Voir aussi PHP8 : http://mw.ajlsm.com/wiki/Mont%C3%A9e_en_version_de_PHP

Test version PHP

[modifier | modifier le wikicode]
$ php -v

Version ancienne. Mise à jour de PHP vers 7.3 : https://www.php.net/supported-versions.php

$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install php7.3
$ apt-cache search php7.3 | grep php7.3
$ sudo apt install $(apt list --installed | grep php7.2- | cut -d'/' -f1 | sed -e 's/7.2/7.3/g')
$ sudo apt-get install php7.3-mysql
$ sudo a2dismod php7.2
$ sudo a2enmod php7.3
$ sudo service apache2 restart

Ok

Drush 10 est requis pour D9

-> Modification de composer.json -> ajout de "drush/drush": "^10.0.0 ",

composer update

Ok.

Installation de upgrade status

[modifier | modifier le wikicode]
$ composer require 'drupal/upgrade_status:^3.0’

Installation du module US

[modifier | modifier le wikicode]

Dans Drupal $URL-Drupal_site/admin/modules

Travailler avec Upgrade Status

[modifier | modifier le wikicode]

Rapport de Upgrade Status après installation de PHP 7.3

[modifier | modifier le wikicode]

Voir en infra <ref></ref> La lecture du rapport indique leq actions à mener.

Désinstallation des modules inutilisés

[modifier | modifier le wikicode]
composer remove drupal/bbr drupal/bootstrap_paragraphs drupal/ckeditor_media_embed drupal/csv_serialisation drupal/date_range_formatter drupal/smart_date drupal/views_accordion drupal/views_conditional drupal/views_fieldsets drupal/views_simple_math_field drupal/views_taxonomy_term_name_depth
  • Vider les caches
  • .update.php

Le module serialisation_csv ne se désinstalle pas. Il est utilisé par Views Data Export.

Désinstallation de Views Data Export
[modifier | modifier le wikicode]
composer remove drupal/views_data_export
  • Vider les caches
  • .update.php

Ok

Mise à jour vers dernière version de Drupal

[modifier | modifier le wikicode]
Important :
/!\ Faire une copie de .htaccess qui va être remplacé lors de la mise à jour..
composer update
Important :
/!\ Ajouter les instructions spécifiques à Pleade (la sauvegarde faites précédemment) dans le nouveau .htaccess.
  • Vider les caches
  • .update.php

Mise à jour des modules suivants vers une version compatible :

[modifier | modifier le wikicode]
composer require 'drupal/backup_migrate:^5.0@RC' 'drupal/crop:^2.1' 'drupal/devel:^4.0' 'drupal/linkit:^6.0@beta' 'drupal/sitemap:^2.0@beta' 'drupal/social_media:^1.9@RC' 'drupal/bootstrap_barrio:^5.1'

Message d’erreur lors de vider les caches :

Error : Class 'BackupMigrate\Drupal\EntityPlugins\SourcePluginManager' not found dans Drupal\Component\DependencyInjection\Container->createService() (/home/ajlsm/drupals/internet/web/core/lib/Drupal/Component/DependencyInjection/Container.php ligne 259)

Lancer :

  • .update.php

Ok

  • Vider les caches

Mise à jour des modules OK.

Mise à jour des modules contribues

[modifier | modifier le wikicode]

Premier essai de compatibilité : On ajoute la ligne suivante dans le fichier [module-name].info.yml de chaque module :

core_version_requirement: ^8 || ^9
  • $drupal_site/modules/menu_export -> suppression de l’indication de version en dur : version:…
  • $drupal_site/modules/responsive_menus
  • $drupal_site/modules/stickynav -> suppression de l’indication de version en dur : version: '8.x-1.1’
  • $drupal_site/modules/views_slidshow_cycle2

Le thème bootstrap barrio est indiqué comme « non prêt » localement.

C’est à cause du sous-thème Pleade_barrio qu’il faut rendre compatible.

  • $drupal_site/theme/custon/pleade_barrio -> suppression de l’indication de version en dur :
version: 8.0.1

ET

# Information added by Drupal.org packaging script on 2019-02-28
version: '8.x-4.22'
core: '8.x'
project: 'bootstrap_barrio'
datestamp: 1551325396
  • Le module pleade doit être récupéré sur le SVN dans le projet Drupal/branches/drupal8/modules/custom/pleade

Il est remplacé « à la main » dans $drupal_site/modules/custom/pleade

  • Vider les caches
  • .update.php

Rapport US (2) La migration est prête pour un upgrade vers Drupal 9

[modifier | modifier le wikicode]

Voir le rapport <ref></ref>

Ok

Sauvegarde de Drupal Pandor2020

[modifier | modifier le wikicode]

Erreur :

The website encountered an unexpected error. Please try again later.
Error: Call to a member function create() on null in Drupal\backup_migrate\Core\Source\MySQLiSource->exportToFile() (line 47 of modules/contrib/backup_migrate/src/Core/Source/MySQLiSource.php).

Recherche patch : https://www.drupal.org/files/issues/2020-10-22/backup_migrate-n3177961-7.patch

Intégration du patch dans /$drupal_site/web/patches/MySQLiSource.patch

Ajout de la prise en compte du patch dans composer.json

,
"drupal/backup_migrate": {
	"Notice Error : Error: Call to a member function create() on null in Drupal...MySQLiSource->exportToFile()).": "web/patches/MySQLiSource.patch"
}
composer update

Problème résolu pour cette version de backup_migrate

Upgrade vers D9

[modifier | modifier le wikicode]
Important :
Avant toute chose : désinstallation du module Upgrade Status dans Drupal.
  • Début upgrade vers D9
chmod 777 web/sites/default
find web/sites/default -name "*settings.php" -exec chmod 777 {} \;
find web/sites/default -name "*services.yml" -exec chmod 777 {} \;
composer require drupal/core-dev:^9.0.0 --dev --update-with-dependencies --no-update
composer update

Echoue.

Important :
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Conclusion: remove drupal/core 8.9.8
    - webflo/drupal-core-require-dev 8.9.8 requires drupal/core 8.9.8 -> satisfiable by drupal/core[8.9.8].
    - webflo/drupal-core-require-dev 8.9.8 requires drupal/core 8.9.8 -> satisfiable by drupal/core[8.9.8].

On supprime "webflo/drupal-core-require-dev": "^8.7.0" de composer.json

OK.

composer require "drupal/core:9.0.7 as 8.9.8" --no-update && composer update
  • .update.php
Erreurs signalées :

Pré-requis non satisfaits

Message d'erreur
Notice: Undefined variable: site_path in system_requirements() (line 716 of core/modules/system/system.install).
Notice: Undefined variable: site_path in system_requirements() (line 716 of core/modules/system/system.install).
Notice: Undefined variable: site_path in system_requirements() (line 716 of core/modules/system/system.install).
Erreurs trouvées

 Configuration sync directory
Absent
Your /settings.php file must define the $settings['config_sync_directory'] setting as a string containing the directory in which configuration files can be found.
Vérifié

Corrigé par l’ajout de la variable suivante dans setting.php :

$settings['config_sync_directory'] = '.';

Ok.

  • .update.php

Met à jour system.install

Erreurs : Error: Call to undefined function drupal_installation_attempted() in bootstrap_library_page_attachments() (line 20 of modules/contrib/bootstrap_library/bootstrap_library.module).

Recherche de patch : https://www.drupal.org/files/issues/2020-07-18/3159690-2.patch

Ajout du patch dans $drupal_site/web/patches/bootstrap_library.patch

Ajout dans composer.json dans la section patches de :

,
"drupal/bootstrap_library": {
	"Notice Error : Error: Call to undefined function drupal_installation_attempted() in bootstrap_library_page_attachments() (line 20 ": "web/patches/bootstrap_library.patch"
}

On lance :

composer update
  • Vider les caches
  • .update.php

Nouvelle erreur Bootstrap dans bootstrap_library.module

Impossible d'appliquer 2 patchs en même temps.

Ci-dessous le début du fichier à recopier si problème de la ligne 0 à la ligne 122

/**
 * @file
 * Primarily Drupal hooks.
 */

use Drupal\Core\Url;
use \Drupal\Core\Installer\InstallerKernel;

define('BOOTSTRAP_MIN_PLUGIN_VERSION', '2.0.0');

/**
 * Implements hook_page_attachments().
 *
 * Use Libraries API to load the js & css files into header.
 */
function bootstrap_library_page_attachments(array &$page) {
  // Don't add the JavaScript and CSS during installation.
  if (InstallerKernel::installationAttempted()) {
    return;
  }
  // Don't add the JavaScript and CSS on specified paths or themes.
  if (!_bootstrap_library_check_theme() || !_bootstrap_library_check_url()) {
    return;
  }
  $config = \Drupal::config('bootstrap_library.settings');
  $cdn = ($config->get('cdn.bootstrap'));
  if ($cdn) {
    $page['#attached']['library'][] = 'bootstrap_library/bootstrap-cdn';
  }
  else {
    $variant_options = ['source', 'minified', 'composer'];
    $variant = $variant_options[$config->get('minimized.options')];
    switch ($variant) {
      case 'minified':
        $page['#attached']['library'][] = 'bootstrap_library/bootstrap';
        break;
      case 'source':
        $page['#attached']['library'][] = 'bootstrap_library/bootstrap-dev';
        break;
      case 'composer':
        $page['#attached']['library'][] = 'bootstrap_library/bootstrap-composer';
        break;
    }
  }
}

/**
 * Implements hook_library_info_build().
 */
function bootstrap_library_library_info_build() {
  $libraries = [];
  $config = \Drupal::config('bootstrap_library.settings');
  $cdn = ($config->get('cdn.bootstrap'));
  if ($cdn) {
    $data = ($config->get('cdn.options'));
    $cdn_options = json_decode($data);
    $list = _bootstrap_library_object_to_array($cdn_options->bootstrap);
    if (!is_array($list[$cdn]['js'])) {
      $list[$cdn]['js'] = array($list[$cdn]['js']);
    }
    $css_uri = $list[$cdn]['css'];
    $libraries['bootstrap-cdn'] = [
      'dependencies' => [
        'core/jquery',
      ],
    ];
    $libraries['bootstrap-cdn']['css']['base'][$css_uri] = [
      'type' => 'external',
    ];
    foreach ($list[$cdn]['js'] as $js_uri) {
      $libraries['bootstrap-cdn']['js'][$js_uri] = [
        'type' => 'external',
      ];
    }
  }
  return $libraries;
}

/**
 * Verify if current theme is selected.
 */
function _bootstrap_library_check_theme() {
  $config = \Drupal::config('bootstrap_library.settings');

  $theme = \Drupal::theme()->getActiveTheme()->getName();
  $valid_themes = $config->get('theme.themes');
  $visibility = $config->get('theme.visibility');
  $theme_match =  !empty($valid_themes) && in_array($theme, $valid_themes);
  $theme_match = !($visibility xor $theme_match);
  return $theme_match;
}

/**
 * Check if bootstrap_library should be active for the current URL.
 *
 * @return bool
 *   TRUE if bootstrap_library should be active for the current page.
 */
function _bootstrap_library_check_url() {
  // Make it possible deactivate bootstrap with
  // parameter ?bootstrap_library=no in the url.
  if (isset($_GET['bootstrap']) && $_GET['bootstrap'] == 'no') {
    return FALSE;
  }

  // Assume there are no matches until one is found.
  $page_match = FALSE;

  // Convert path to lowercase. This allows comparison of the same path
  // with different case. Ex: /Page, /page, /PAGE.
  $config = \Drupal::config('bootstrap_library.settings');
  $pages = mb_strtolower(_bootstrap_library_array_to_string($config->get('url.pages')));

  // Compare the lowercase path alias (if any) and internal path.
  $path = Url::fromRoute('<current>')->toString();
  $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
  $path_alias = mb_strtolower(\Drupal::service('path_alias.manager')->getAliasByPath($path, $langcode));
  $page_match = \Drupal::service('path.matcher')->matchPath($path_alias, $pages);
  if ($path_alias != $path) {
    $page_match = $page_match || \Drupal::service('path.matcher')->matchPath($path, $pages);
  }
  $page_match = $config->get('url.visibility') == 0 ? !$page_match : $page_match;

  return $page_match;

}

Dernière erreur :

Fichier themes/custom/pleade_barrio/pleade_barrio.theme ligne 44, modification path.alias_manager en path_alias.manager.

Modifier ligne 44 :

Fichier themes/custom/pleade_barrio/pleade_barrio.theme ligne 44, modification path.alias_manager en path_alias.manager..

Une dernière chose :

  • Remettre les instructions pour Pleade dans .htaccess

Migration terminée.

[modifier | modifier le wikicode]

Une fois terminé, restaurez l'accès en lecture seule aux répertoires et fichiers suivants :

chmod 755 web/sites/default
find web/sites/default -name "*settings.php" -exec chmod 644 {} \;
find web/sites/default -name "*services.yml" -exec chmod 644 {} \;

Autres problèmes après une migration réussit

[modifier | modifier le wikicode]

Pour les mises à jour suivantes, il faut modifier composer.json pour toujours conserver la compatibilité des modules non maintenus en attendant leur remplacement et leur suppression.

Maintenir la compatibilité de certains modules avec D8

[modifier | modifier le wikicode]

Par exemple, pour réaliser la migration de D 8.9.8 en 9.0.7, vous avez indiqué ce qui suit dans composer.json  :

"drupal/core": "9.0.7 as 8.9.8",

Avant de mettre à jour Drupal vers la nouvelle version D 9.0.8, modifiez la ligne comme suit :

"drupal/core": "9.0.8 as 8.9.8",

Drupal va garder la compatibilité des modules.

Supprimer la compatibilité de certains modules avec D8

[modifier | modifier le wikicode]

Par exemple, pour voir si tous vos modules sont compatibles.

En modifiant :

"drupal/core": "9.0.8 as 8.9.8",

par :

"drupal/core": "^9.0.0",

La mise à jour peut bloquer sur les modules non maintenus et lister de nouveaux problèmes.

Un exemple :

Problem 1
    - The requested package drupal/core (locked at 9.0.7, required as 9.0.8) is satisfiable by drupal/core[9.0.7] but these conflict with your requirements or minimum-stability.
  Problem 2
    - drupal/views_slideshow_cycle2 1.x-dev requires drupal/core ~8.0 -> satisfiable by drupal/core[8.0.x-dev, 8.1.x-dev, 8.2.x-dev, 8.3.x-dev, 8.4.x-dev, 8.5.x-dev, 8.7.x-dev, 8.8.x-dev, 8.9.x-dev].

Plusieurs solutions :

  • Installer une version D9 du module views_slideshow_cycle2, ou
  • remplacer le module par un autre compatible D9, ou
  • supprimer le module s'il n'est pas utilisé


== Références == <references/>