Warning: Undefined property

Created on 24 February 2025, about 2 months ago

All was working fine on my Drupal 10 site, and today, all of a sudden, I get this warning when trying to add slides to carousel:
Warning: Undefined property: Drupal\Core\Extension\Extension::$base_theme in dxpr_builder_media_preprocess_views_view() (line 20 of modules/contrib/dxpr_builder/modules/dxpr_builder_media/dxpr_builder_media.module).
Please advise.

💬 Support request
Status

Active

Version

2.6

Component

Miscellaneous

Created by

🇫🇷France stado

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @stado
  • 🇫🇷France stado

    1. Solution for the warning:

    Replace this code in DXPR Builder Media module file:
    function dxpr_builder_media_preprocess_views_view(array &$variables): void {
    if ($variables['view']->id() === 'dxpr_builder_media') {
    // Get the active theme.
    $active_theme = \Drupal::theme()->getActiveTheme()->getName();

    // Get the base theme of active theme.
    /* @phpstan-ignore-next-line */$base_theme = \Drupal::service('theme_handler')->listInfo()[$active_theme]->base_theme;

    // Check if the active theme or base theme is 'gin'.
    if ($active_theme === 'gin' || $base_theme === 'gin') {
    $variables['view_array']['#attached']['library'][] = 'dxpr_builder_media/gin_style';
    }
    else {
    $variables['view_array']['#attached']['library'][] = 'dxpr_builder_media/claro_style';
    }
    $variables['view_array']['#attached']['library'][] = 'dxpr_builder_media/view';
    }
    }

    With this code:
    function dxpr_builder_media_preprocess_views_view(array &$variables): void {
    if ($variables['view']->id() === 'dxpr_builder_media') {
    // Get the active theme.
    $active_theme = \Drupal::theme()->getActiveTheme()->getName();

    // Get the base theme of active theme.
    /* @phpstan-ignore-next-line */
    $theme_handler = \Drupal::service('theme_handler');
    $theme_info = $theme_handler->listInfo()[$active_theme] ?? null;
    $base_theme = $theme_info && isset($theme_info->info['base theme']) ? $theme_info->info['base theme'] : null;

    // Check if the active theme or base theme is 'gin'.
    if ($active_theme === 'gin' || $base_theme === 'gin') {
    $variables['view_array']['#attached']['library'][] = 'dxpr_builder_media/gin_style';
    }
    else {
    $variables['view_array']['#attached']['library'][] = 'dxpr_builder_media/claro_style';
    }
    $variables['view_array']['#attached']['library'][] = 'dxpr_builder_media/view';
    }
    }

    2. Solution for the error:

    Install RAT:
    composer require drupal/rat
    drush cr

    Enjoy

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024