Skip to content

FIX: inherited advanced validation detection https://github.com/Crocoblock/issues-tracker/issues/18989 - #686

Merged
ObitoTM merged 2 commits into
release/3.6.5from
issue/18989
Jul 29, 2026
Merged

FIX: inherited advanced validation detection https://github.com/Crocoblock/issues-tracker/issues/18989#686
ObitoTM merged 2 commits into
release/3.6.5from
issue/18989

Conversation

@ObitoTM

@ObitoTM ObitoTM commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions

Copy link
Copy Markdown

🤖 AI PR Review

Risk level: low

Review

Summary

  • This PR fixes detection of inherited advanced validation by treating validation.type === 'inherit' as falling back to the form-level setting. It also fixes a file-size validation bug (<= vs <) in FileSizeRestriction and updates the built frontend assets.

Files of interest

  1. modules/validation/module.php
  • Change: is_advanced() now returns true when validation.type === FORMAT_ADVANCED; when validation.type is '' or 'inherit' it falls back to is_advanced_form(); otherwise returns false.
  • Effect: 'inherit' now behaves like an empty value and will use the form-level advanced setting. This addresses the bug where 'inherit' was treated as a concrete (non-advanced) value.
  • Back-compat: This is a safe change — previous behavior was FORMAT_ADVANCED === $type for any non-empty type, so other values still yield false. The only semantic change is special-casing 'inherit' to fallback, which is the intended behaviour and is backwards compatible in practice.
  • Suggestions:
    • Normalize the input: consider trimming/casting to string (e.g. $type = trim( (string) ( $block_attrs['validation']['type'] ?? '' ) );) before comparisons to avoid edge cases (extra whitespace, nulls, etc.).
    • Add a unit test for is_advanced() covering: FORMAT_ADVANCED, '', 'inherit', and an unrelated string value to ensure the behaviour remains correct.
  1. assets/src/frontend/media.field.restrictions/FileSizeRestriction.js (and built assets)
  • Change: validate now uses <= (less-than-or-equal) instead of <. This is correct: a file sized exactly equal to the configured max should be allowed.
  • Built assets (assets/build/...) were updated accordingly. Ensure the built files are expected (i.e. the build step was run and committed intentionally).
  • Suggestion: Add a small unit or integration test to cover the exact-equality case for file sizes so regressions are caught.

General notes

  • Security: No security-sensitive changes detected. Nothing touching nonces, capabilities, DB, or sanitization.
  • Performance: No performance regressions. Changes are minor logic fixes.
  • Multisite / integrations: No effect.
  • Tests: High-value to add tests around the is_advanced behavior and the FileSizeRestriction boundary (<=).
  • Developer workflow: Since built assets were committed, confirm this matches the repo's policy (committed builds vs CI-built). If builds are committed, ensure the source JS and build output are both updated consistently (they are, in this PR). Also note a missing newline at EOF in one of the earlier builds was fixed — trivial.

Recommendation

  • Approve after adding or scheduling unit tests to cover the changed behaviours and optionally normalizing $type in is_advanced().

Suggested changelog entry

- FIX: inherited advanced validation detection in validation module (respect "inherit" to use form-level advanced setting)

@ObitoTM
ObitoTM merged commit 5b2d4e2 into release/3.6.5 Jul 29, 2026
1 check 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.

1 participant