Skip to content

Fix taxonomy term ID parsing in surveillance threshold sanitizer#424

Merged
JLG-WOCFR-DEV merged 1 commit intocodex/fix-redeclaration-of-blc_sanitize_surveillance_thresholds_opfrom
codex/fix-sanitizer-for-term-id-strings
Oct 18, 2025
Merged

Fix taxonomy term ID parsing in surveillance threshold sanitizer#424
JLG-WOCFR-DEV merged 1 commit intocodex/fix-redeclaration-of-blc_sanitize_surveillance_thresholds_opfrom
codex/fix-sanitizer-for-term-id-strings

Conversation

@JLG-WOCFR-DEV
Copy link
Owner

Summary

  • pre-process taxonomy surveillance thresholds to coerce term IDs from strings to integer arrays
  • skip taxonomy thresholds that do not target any term when "apply to all" is disabled
  • continue normalizing and persisting thresholds via the shared helper

Testing

  • php -l liens-morts-detector-jlg/includes/blc-settings-fields.php

https://chatgpt.com/codex/tasks/task_e_68f3f91f5f38832e812814ffb86e6b57

@JLG-WOCFR-DEV JLG-WOCFR-DEV merged commit 0504098 into codex/fix-redeclaration-of-blc_sanitize_surveillance_thresholds_op Oct 18, 2025
1 check failed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

foreach ($value['taxonomy'] as $definition) {
if (!is_array($definition)) {
continue;
}
$apply_to_all = !empty($definition['apply_to_all_terms']);
$term_ids = array();
if (isset($definition['term_ids'])) {
$raw = $definition['term_ids'];
if (is_string($raw)) {
$parts = preg_split('/[,\s]+/', $raw);
} elseif (is_array($raw)) {
$parts = $raw;
} else {
$parts = array();
}
foreach ($parts as $part) {
$term_id = (int) $part;
if ($term_id > 0) {
$term_ids[] = $term_id;
}
}
}
if (!$apply_to_all && $term_ids === array()) {
continue;
}
$definition['term_ids'] = $term_ids;
$definition['apply_to_all_terms'] = $apply_to_all;
$structured['taxonomy'][] = $definition;

P1 Badge Preserve apply-to-all toggle when previous term IDs exist

The new sanitizer always parses term_ids even when the user selected “apply to all”. blc_normalize_surveillance_threshold_group later recomputes apply_to_all_terms purely from whether term_ids is empty. If a saved taxonomy threshold previously targeted specific terms and the user switches the checkbox to apply to all without manually clearing the textarea, the sanitized payload will still carry the old term_ids array and normalization will flip the flag back to false. The user therefore cannot change an existing threshold to apply to all terms unless they also clear the term IDs field, which the UI may hide. Consider clearing term_ids when $apply_to_all is true before handing off to the normalizer.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant