Error: Call to a member function getString() on null in alerts_views_pre_render() (line 24 of modules/contrib/alerts/alerts.module).

Created on 14 November 2022, over 2 years ago
Updated 18 April 2024, 12 months ago

Problem/Motivation

Error: Call to a member function getString() on null in alerts_views_pre_render() (line 24 of modules/contrib/alerts/alerts.module).

Steps to reproduce

Getting this on the node view page

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India ankit agrawal

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada mandclu

    The configuration for that vocabulary is provided by the module, and should have been imported when the module was installed. Did you encounter any errors during install?

    Actually, looking at the module's code I believe I see the problem. For the import of the configuration to work as expected the taxonomy module needs to be installed, but it isn't listed as a requirement in alerts.info.yml. I will update to fix that, but that won't help a site where this module is already installed.

    If you're still having this problem I would suggest manually importing the taxonomy.vocabulary.alert_severity.yml configuration file.

    • mandclu committed 21938939 on 1.1.x
      Issue #3321053 by mandclu: Error: Call to a member function getString()...
  • Status changed to Fixed 12 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • First commit to issue fork.
  • 🇦🇹Austria shyam-sawhney

    Hello @mandclu

    It's a very nice module thanks for it. But this issue is not related to import.

    install YML are working perfectly and creating Taxonomy and field once we are installing it. It's a issue in fetch. The field_color is not considering the default untill you hit a save on individual Taxonomy.

    error is in alerts.module

    a possible easy fix is.

    $colors = [];
    foreach ($terms as $tid => $term) {
    if($term) {
    if( $term->get('field_color')->getValue()){
    $color = $term->field_color->first()->getString();
    $colors[$tid] = '.alert-severity-' . $tid . ' { background: ' . $color . '; }';
    }
    }
    }

    created a MR

Production build 0.71.5 2024