Skip to content

[3.0] Label a spoiler that was given no summary of its own - #9420

Merged
Sesquipedalian merged 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/spoiler-summary-label
Aug 30, 2026
Merged

[3.0] Label a spoiler that was given no summary of its own#9420
Sesquipedalian merged 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/spoiler-summary-label

Conversation

@albertlast

@albertlast albertlast commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Description

A spoiler with no summary of its own renders <summary class="bbc_summary"></summary> — a details element with nothing in the part you are meant to click.

There are two fallbacks and neither works.

Spoiler2 (the [spoiler="…"] form) asks for a string that does not exist:

$data = Lang::getTxt('summary_default', var: 'editortxt');

No language file defines summary_default, and Lang::getTxt() returns '' for a key it cannot find, so nothing is logged and nothing is drawn.

Spoiler1 (the [spoiler] form, which becomes a details element when the content has more than one paragraph) has the right key but the wrong test:

'summary' => $params['{text}'] ?? Lang::getTxt('spoiler', var: 'editortxt'),

The parser fills every optional parameter in, as an empty string rather than leaving it unset, so ?? never falls back. Dumping $params for a plain [spoiler]:

array (
  '{guests}' => '', '{hide}' => '', '{log}' => '', '{log_id}' => '',
  '{quote}' => '', '{show}' => '', '{text}' => '',
)

The branch is only entered when !empty($params['{text}']) is false or the content has paragraphs, so in the paragraph case {text} is known to be empty by the time ?? is asked — it could never have fired.

Details::validate() a few files over gets both parts right, and its $editortxt['details'] is the model for this, so $editortxt['spoiler'] is what I used rather than adding a summary_default string.

I also named the language file on both calls. Editor.php happens to be loaded on a topic view already, so this is not what was breaking them, but neither call said where its string lives.

Verified on a local 3.0 install, three posts:

BBCode before after
[spoiler=""]hidden[/spoiler] <summary class="bbc_summary"></summary> <summary class="bbc_summary">Spoiler</summary>
[spoiler] with two paragraphs <summary class="bbc_summary"></summary> <summary class="bbc_summary">Spoiler</summary>
[details]plain[/details] <summary class="bbc_summary">Details</summary> unchanged

One thing I noticed while testing and did not touch: a multi-paragraph [spoiler] leaves its closing tag in the output as literal text (second paragraph[/spoiler]) while still emitting </div></details> at the end. That happens on release-3.0 too and is unrelated to the label — filed separately as #9421.

Issues References (Fixes|Related|Closes)

Related: #9421

Neither fallback worked. One asked for summary_default, which no language
file defines, so getTxt() returned an empty string. The other used ??
against a parameter the parser fills in as '' rather than leaving unset,
so it never reached its fallback either. Both draw an empty summary,
which is a details element with nothing to click.

Use the editortxt string the details tag already falls back to, name the
file it lives in, and test the parameter with ?: so an empty one counts.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Comment thread Sources/BBCode/Spoiler1.php Outdated
@Sesquipedalian
Sesquipedalian merged commit 2337398 into SimpleMachines:release-3.0 Aug 30, 2026
7 checks passed
@jdarwood007 jdarwood007 modified the milestones: 3.0 Alpha 6, 3.0 Alpha 5 Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants