Skip to content

Validate "Excluded topic IDs" and let the field be cleared - #220

Merged
avandenberghe merged 1 commit into
develop33from
issue-217-anti-topics-input
Oct 4, 2026
Merged

avandenberghe merged 1 commit into
develop33from
issue-217-anti-topics-input

Conversation

@avandenberghe

Copy link
Copy Markdown
Collaborator

Closes #217.

Problem (raised in the customisations team's 3.0.11 review)

  • The ACP saved rt_anti_topics only when every comma-separated entry was numeric. Otherwise it silently kept the old value but still showed "Configuration updated".
  • An empty field never saved: explode(',', '') gives [''], which isn't numeric, so the list couldn't be cleared (the workaround was 0).

Fix (acp/recenttopics_module.php)

  • New normalise_anti_topics(): trims entries, drops empty ones (a trailing comma, a blank field) and duplicates, and turns an empty list into '0' (exclude nothing). It returns null if any entry isn't a whole number.
  • main() runs the check right after the form-key check, before any setting is written. Invalid input shows the new RT_ANTI_TOPICS_INVALID error and nothing is saved.
  • RT_ANTI_TOPICS_INVALID is translated in all 14 ACP language packs.

Tests

  • New tests/acp/anti_topics_test.php: 11 inputs, from valid lists, spacing, duplicates, a trailing comma and an empty field to text, decimals and negatives. All errored before the helper existed.
  • New functional tests (CI): invalid input shows the error and leaves the stored value unchanged; clearing the field stores 0.
  • tests/tests.md updated. Unit suite: 101 tests, 0 failures, run locally. CI result to follow.
  • Not run on the board: the save path needs a logged-in admin session. The functional tests cover it in CI. A stored 0 is what the topic query already treats as "exclude nothing".

This folds into 3.0.12; its changelog line comes with the 3.0.12 changelog update.

🤖 Generated with Claude Code

The ACP saved rt_anti_topics only when every comma-separated entry was
numeric, and otherwise dropped the input while still reporting
"Configuration updated". An empty field never saved either: explode()
gives [''], which is not numeric, so the list could not be cleared.

normalise_anti_topics() trims entries, drops empty ones and duplicates,
and turns an empty list into '0' (exclude nothing). Any entry that is
not a whole number makes the ACP show RT_ANTI_TOPICS_INVALID and save
nothing; the check runs before any setting is written. The new
language key is translated in all 14 packs.

Closes #217

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@avandenberghe
avandenberghe merged commit d7f68e3 into develop33 Oct 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP "Exclude topics" silently ignores invalid input and can't be cleared

1 participant