Patches, Workarounds and Special Solutions for Drupal 8/9

Patches, Workarounds and Special Solutions for Drupal 8/9

Patches, workarounds and special solutions for the migration to drupal 8 will be collected in this section.

admin_wla Tue, 04/27/2021 - 11:19
0
0

Changed Session Lifetime

Changed Session Lifetime

On 26.4.2021 the session lifetime was changed to one day. When the system goes life it will be shortend even to 6 hours.

The change has been don in the file sites/default/sevices.yml. Lifetime is set in seconds.

 

wla

admin_wla Mon, 04/26/2021 - 12:25
0
0

Reenabled Caption on Main-Article-Image

Reenabled Caption on Main-Article-Image

In the Drupal 7 version the caption of the main article images was handelt by two bits:

  • The function hook_preprocess_image() in the theme to add the class "caption" to the image tag
  • The module image_caption which added a jQuery-Function to do the work

The module doesn't exist for Drupal 8. The preprocess_image hook luckily still is available.

  • With adding the function in the .theme-file of our theme, it was feasable to add the class "caption" to an image set by an image-field when the images style is w225xh150.
  • The jQuery-Function was put into the themes js directory into the file "drupal8_w3css_subtheme.theme". There the function worked as in the Drupal 7 version.

Mission accomplished

Caution: when in Drupal 10 jQuery is eliminated, the script has to be rewritten.

admin_wla Tue, 04/27/2021 - 09:34
0
0

Workaround for bug Non-translatable fields can only be changed when updating the original language.

Workaround for bug Non-translatable fields can only be changed when updating the original language.

Workarount for the bug " Non-translatable fields can only be changed when updating the original language"

Found on https://www.drupal.org/project/drupal/issues/2955321

Created a custom module "wla_enable_translations" to overcome this issue. Code

function wla_enable_translations_entity_type_alter(array &$entity_types) {
  foreach ($entity_types as $entity_type) {
    $constraints = $entity_type->getConstraints();
    unset($constraints['EntityUntranslatableFields']);
    $entity_type->setConstraints($constraints);
  }
}

admin_wla Tue, 04/27/2021 - 11:21
0
0

Duplicate page element in breadcrumbs

Duplicate page element in breadcrumbs

The breadcrumbs showed the page Element twice in the breadcrumbs. Finally I've found that in Drupal 8 the page title as the final element is handled by Drupal. The Theme D8W3CSS however has a proprocess_breadcrumb-function which adds the page-title if it's not empty. Thus the title shows up twice.

Solution: deactivating the proprocess_breadcrumb-function in the theme D8W3CSS

admin_wla Tue, 04/27/2021 - 13:56
0
0

Get rid of error messages regarding non existing fields

Get rid of error messages regarding non existing fields

[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_internal_information, field name: comment_body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_recommendedpractices_details, field name: comment_body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_recommendedpractices_stepbystep, field name: comment_body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_recommended_practices, field name: comment_body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_glidenumber, field name: comment_body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_geo_information_resource, field name: comment_body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_projects, field name: comment_body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_un_spider_training_activity, field name: comment_body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: glidenumber, field name: body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: projects, field name: body
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: glidenumber, field name: upload
[error]  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: projects, field name: upload

The installation shows error messages regarding no longer existing fields which partially existed back in the Drupal 6 version of spider and are long gone. The Update processes from Drupal 6 to Drupal 7 to Drupal 8 however saved this old information in the database. The removal of those definitions can only be done via programming (see https://codimth.com/blog/web/drupal/how-fix-non-existent-config-entity-name-drupal-8-9, example 3).

By using update hooks in the custom module "practical_use" these errors could be removed one by one.

 

admin_wla Sun, 10/17/2021 - 17:36
0
0
wla

Implemented patch for views

Implemented patch for views

Invalid config structures can result in exceptions when saving a config entity Issue https://www.drupal.org/project/drupal/issues/2925890 Under certain conditions a view cannot be saved after editing. This patch solve the problem.

Drupal version: 9.3.7

admin_wla Sat, 03/05/2022 - 18:11
0
0
wla

Implemented patch for views with duplicate nodes

Implemented patch for views with duplicate nodes

Views relationships with multi-valued entity reference fields invalidate Distinct query option

(https://www.drupal.org/project/drupal/issues/2993688)

This is an issue with a lot of views in the installation which make use of entity relationships. Using the module views_distinct often results in wrong numbering in the pager which results in empty spaces in a multi-page view. This patch is a first solution for it but need further observation.

Implemented 8th of March 2022

wla

admin_wla Tue, 03/08/2022 - 15:58
0
0
wla

Introduce Practical Use and Practical Use Details as content types

Introduce Practical Use and Practical Use Details as content types

Exported types "recommended practices" and "recommended practices details" into the custom module "pract_uses". By mass changing the filenames and mass editing the files these types got converted into the content types "practical use" and "practical use details". When activating this module these content types will become active and stay even if the module gets deactivates and removed later.

admin_wla Sun, 10/17/2021 - 16:21
0
0
wla

Issue with duration in smart Date

Issue with duration in smart Date

In forms with smart-date field types there is an issue that the duration field can't be set and gives the issue "This value should be of the correct primitive type.".

The reason is, that the default duration is not set to an integer but to an empty string. Setting the value to 0 cures the problem.

The fix has to be applied in line 230 of web/modules/contrib/smart_date/src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php in setting $default_duration = 0;

19.5.2021 wla

admin_wla Wed, 05/19/2021 - 16:20
0
0

Language Switcher block should only show available languages in the related language

Language Switcher block should only show available languages in the related language

Language switcher block is not handled via the "block_layout" page but called directly in the file "page.html.twig" in the used subtheme.

To ensure, that only available languages are shown, the function hook_preprocess_links__language_block() is used in the .theme file of the theme. Actually any language but 'en', 'es' and 'fr' gets removed from the link list and the title attribute of the accepted link get changed to the title of the corresponding language.

admin_wla Tue, 05/04/2021 - 13:17
0
0

Limit years in Date select fields

Limit years in Date select fields

In the standard Drupal 8.9.15 version, there is no way to limit the year range of date fields. There was however a patch which solved this issue

https://www.drupal.org/project/drupal/issues/2836054 (#50)

Even if that patch is designed for Drupal 9.3 it installed seamlessly for Drupal 8.9.15.
After the installation of that patch there are start- and end-year field in the widget configuration of the date field.

admin_wla Mon, 05/24/2021 - 17:50
0
0

Rework the frontpage slideshow

Rework the frontpage slideshow

Define 2 new image styles:

  • w1214x320
  • w300x80

Modify the field featured image in news content type:

  • Set max and min dimensions to 1214x320 pixel (i.e. the image must exactly have these dimensions)
  • Change help text for featured image to explain, that we need the correct dimensiones
  • Change the preview image to style w300x80 to get a better feeling for the result

Change the image style for featured image in the view frontpage slideshow to w1214x320.

 

admin_wla Fri, 12/03/2021 - 13:14
0
0
Werner Lappessen

Transliteration in core not working for file names

Transliteration in core not working for file names

The transliteration-Module from Drupal 7 was moved into core in Drupal 8. There is however an outstanding bug related to transliteration of file names. There are discussions how to handle this, but the bug is still not fixed. As a work around someone wrote the module 'transliterate_filenames" to do the work. This module only has to be installed and enabled to handle transliteration of filenames in future.

admin_wla Tue, 05/11/2021 - 13:51
0
0

View issue with OR-group

View issue with OR-group

In the view "list all spider activities" there is the block "Block remote TAS". This display has an "AND" and an "OR" group in the filter section. With the OR-group in place, the was no result even with simpler conditions. Searching through the issue list led to a core issue for views which finally resulted in a patch (https://www.drupal.org/files/issues/2020-10-14/2559961-101.patch). After applying this patch the view worked as expected. This needs to be checked when the upgrade to Drupal 9 should be done.

admin_wla Tue, 05/11/2021 - 13:26
0
0