I will examine the implementation of the update process in the OpenY distribution
A few topics that will be covered:
- Main disadvantages of updating existing distributions
- How these problems were solved in the distribution of OpenY
- Separation of the openy_upgrade_tool module into a contrib project
- Problems to be Solved
3. Table of contents
● A few words about OpenY distro
● How to support upgrade path for the distribution?
● Upgrade path in existing Drupal 8 distributions
● Upgrade path challenge for the OpenY team
● Upgrade tool module
4.
5. More info about OpenY
DrupalCon Baltimore
Scaling and Sharing: Building Custom Drupal Distributions
for Federated Organizations
(Alex Schedrov & Craig Paulnock)
https://events.drupal.org/baltimore2017/sessions/leveraging-open-source-scalability-federated-organizations
Drupal Case Studies: “Open Y: Drupal Distribution for YMCA's”
https://www.drupal.org/node/2870762
http://openymca.org/
8. /**
* Changes the media_library CKEditor button to media_browser.
*/
function lightning_media_update_8009() {
/** @var DrupaleditorEditorInterface $editor */
$editor = Editor::load('rich_text');
if ($editor) {
$settings = $editor->getSettings();
foreach ($settings['toolbar']['rows'] as &$row) {
foreach ($row as &$group) {
$index = array_search('media_library', $group['items']);
if ($index !== FALSE) {
$group['items'][$index] = 'media_browser';
}
}
}
$editor->setSettings($settings)->save();
}
}
How updates look like ?
hook_update_N
https://api.drupal.org/api/drupal/core%21lib
%21Drupal%21Core%21Extension%21mo
dule.api.php/function/hook_update_N/8.2.x
hook_post_update_NAME
https://api.drupal.org/api/drupal/core%21lib
%21Drupal%21Core%21Extension%21mo
dule.api.php/function/hook_post_update_N
AME/8.2.x
9. /**
* Creates the media browser display of the media view.
*/
function lightning_media_update_8008() {
/** @var DrupalviewsViewEntityInterface $view */
$view = View::load('media');
// Sanity check.
if (empty($view)) {
return;
}
// Views Infinite Scroll powers the pager of the EB display.
if (!Drupal::moduleHandler()->moduleExists('views_infinite_scroll')) {
Drupal::service('module_installer')->install(['views_infinite_scroll']);
}
$display_id = $view->addDisplay('entity_browser', 'Browser');
$display = &$view->getDisplay($display_id);
$display = array_merge($display, array(
'display_options' =>
array(
'display_extenders' =>
array(),
'style' =>
array(
'type' => 'grid',
'options' =>
array(
...
https://github.com/acquia/lightning/blob/8.x-1.x/modul
es/lightning_features/lightning_media/lightning_medi
a.install#L150
10. /**
* Adds the library filter to the media view's Entity Browser display.
*/
function lightning_media_update_8012() {
/** @var Drupalentity_browserEntityBrowserInterface $browser */
$browser = EntityBrowser::load('media_browser');
if (empty($browser)) {
return;
}
/** @var Drupalentity_browserWidgetInterface $widget */
foreach ($browser->getWidgets() as $widget) {
if ($widget->getPluginId() == 'view') {
$configuration = $widget->getConfiguration();
if ($configuration['settings']['view'] == 'media') {
/** @var DrupalviewsViewEntityInterface $view */
$view = View::load('media');
// Reference the display options directly, for readability.
$display = &$view->getDisplay($configuration['settings']['view_display'])['display_options'];
// It's possible that the site owner took matters into their own hands
// and configured the filter already, so only add it if it's not there.
if (empty($display['filters']['field_media_in_library_value'])) {
$display['filters']['field_media_in_library_value'] =
unserialize('a:14:{s:2:"id";s:28:"field_media_in_library_value";s:5:"table";s:29:"media__field_media_in_library"
...
https://github.com/acquia/lightning/blob/8.x-2.
x/modules/lightning_features/lightning_media/
lightning_media.install#L203
12. Projects based on OpenY
OpenY
Twin
Cities
Seattle
Houston
Dallas
Brandywine
Long
Island
Dayton
Redwing
13. 1. Sub-task: Confi module
“Right now confi module allows to import specific config(whole file).
We should create patch to be able to revert only specific property from file.”
16. $config = drupal_get_path('module', 'openy_media_image') .
'/config/install/views.view.images_library.yml';
$config_importer = Drupal::service('config_import.param_updater');
$config_importer->update($config, 'views.view.images_library',
'display.default.display_options.pager');
Update only part of config
17. 2. Sub-task: If config has been touched
“When we revert config in upgrade path, we should be able to identify if this
specific config or property has been changed manually.
In this case will be awesome to create page where we can track those conflicts.”
27. Problem with updates between versions
demo_update_8001 Enable some
additional modules
-
demo_update_8002 Add new field to
demo node type
core.entity_form_display.node.demo.default.yml
core.entity_view_display.node.demo.default.yml
field.field.node.demo.field_test1.yml
field.storage.node.field_test1.yml
demo_update_8003 Enable metatag
module
demo_update_8004 Add metatag field
to demo node type
core.entity_form_display.node.demo.default.yml
core.entity_view_display.node.demo.default.yml
field.field.node.demo.field_metatags.yml
field.storage.node.field_metatags.yml
demo_update_8005 - -
New
dependencies to
metatag field
configs
Update error:
Config unmet
dependencies
28.
29. TODO
- Add module report to status page
- Add possibility to select different configs in module settings form
- Add force update action to Upgrade log entity
- Add apply existing config action to Upgrade log entity
- Add configs conflicts resolver