Warning For Rendered Views

Created on 4 May 2022, about 2 years ago
Updated 12 May 2024, about 2 months ago

Problem/Motivation

Watchdog log is being filled with
Notice: Trying to access array offset on value of type null in Drupal\html_title\Plugin\views\field\NodeHtmlTitle->renderText() (line 50 of /app/web/modules/contrib/html_title/src/Plugin/views/field/NodeHtmlTitle.php)

Steps to reproduce

Proposed resolution

Sanity checking for $alter['rendered']['#title']['#context']['value']

Replace line 50-52:

if (!empty($alter['rendered']['#title']['#context']['value'])) {
  $alter['rendered']['#title']['#context']['value'] = $this->htmlTitleFilter->decodeToMarkup($alter['rendered']['#title']['#context']['value']);
}

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ElusiveMind Nashville, TN

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.

  • πŸ‡¨πŸ‡·Costa Rica yuvania

    I checked it, it works fine for me.

  • πŸ‡¨πŸ‡·Costa Rica yuvania
  • πŸ‡¨πŸ‡·Costa Rica yuvania
  • πŸ‡¨πŸ‡·Costa Rica yuvania
  • Status changed to Needs work over 1 year ago
  • First commit to issue fork.
  • Pipeline finished with Success
    about 2 months ago
    Total: 212s
    #168872
  • Status changed to Needs review about 2 months ago
  • πŸ‡ΊπŸ‡¦Ukraine quadrexdev Lutsk

    Moved the changes from #2 in a merge request, and all tests passed.

  • First commit to issue fork.
  • Status changed to RTBC about 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States generalredneck

    So I was trying to reproduce this issue. It seems that there's another issue at play here that actually seems to render the code in the if statement moot anyway because we are checking for $this->options['settings']['link_to_entity'] === TRUE.

    The problem here is that $this->options['settings']['link_to_entity'] is in fact the number 1 instead of the boolean TRUE

    Given that, we need to fix that check so this can be reproducible. Given that, Immediately looking at the code I can see that prior to this fix, $alter['rendered']['#title']['#context']['value'] was always created and always a string or Markup object because of $this->htmlTitleFilter->decodeToMarkup() always returns that type. With this fix, that array item doesn't exist and "may" cause unexpected side effects, but I don't know that for certain. It also seems like this would only ever happen if for what ever reason the "title" was empty some how from upstream.

    No amount of me messing around with a node and view settings in the UI got me an empty value there. So I have to assume that this has to be on some other type of entity and possibly a broken view configuration?

    Given that, after fixing the check in the patch, I'm not receiving any bad side affects. I would feel much more comfortable with steps to reproduce this and/or a view this happens on for us to inspect. However, given the realtivly simple nature of this fix, I'll go ahead and mark it RTBC

Production build 0.69.0 2024