Hello, I've been getting this error message for a few days. Do you know where it might be coming from?"

Warning: Undefined array key "back_to_toc_label" in toc_js_node_view() (line 181 of modules/contrib/toc_js/toc_js.module).

Issue fork toc_js-3544348

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cyril64 created an issue. See original summary.

mably’s picture

Just to clarify, is this showing up only as a warning in the logs, or is it also affecting how your site works?

This code shouldn't generate a warning thoug:

Xss::filter((string) $toc_js_settings['back_to_toc_label'] ?? '', ['span'])

Are you sure you are on latest 3.2.1 version?

EDIT: Ok, it looks like the cast takes precedence over the ??, could you try adding some parenthesis around to see if it fixes your problem ?

Xss::filter((string) ($toc_js_settings['back_to_toc_label'] ?? ''), ['span'])

Created an MR with the fix.

mably’s picture

Status: Active » Needs review
cyril64’s picture

Thank you. It solved the problem with :
Xss::filter((string) ($toc_js_settings['back_to_toc_label'] ?? ''), ['span'])

  • mably committed f66aad84 on 3.x
    Issue #3544348 by mably, cyril64: Warning message
    
mably’s picture

Status: Needs review » Fixed

Thanks for the feedback. Let's merge this!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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