Skip to content

Conversation

@Snider
Copy link
Contributor

@Snider Snider commented Feb 2, 2026

πŸ’‘ What:

  • Added $preparedSchema property to Sanitiser class.
  • Added prepareSchema() method to pre-calculate effective schemas for all configured fields.
  • Updated __construct, withSchema, and applyPresetToFields to rebuild the schema cache when configuration changes.
  • Updated filterString to use the cached $preparedSchema instead of merging on every call.

🎯 Why:

  • The previous implementation called array_merge($globalSchema, $fieldSchema) for every string value filtered.
  • For large datasets (e.g., CSV imports, bulk API processing), this created significant CPU overhead.
  • By caching the merged result, we replace array_merge with a simple array lookup.

πŸ“Š Measured Improvement:

  • Benchmark with 50,000 items and 10 fields (plus global schema) showed:
    • Baseline: ~1.0989s
    • Optimized: ~1.0132s
    • Improvement: ~0.085s (~8%)
  • The improvement is consistent and scales with the number of items.
  • All existing tests passed, including specific Sanitiser tests.

PR created automatically by Jules for task 13909083095903081937 started by @Snider

Replaces repeated array_merge calls in filterString with a pre-calculated cache of effective schemas. This reduces CPU overhead during filtering of large datasets.

Benchmark results showed ~8% improvement (80ms) for 50,000 items.
@google-labs-jules
Copy link

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

QA Pipeline Results

Check Status Details
Tests βœ“ 207 tests, 410 assertions
PHPStan βœ“ 0 errors
Psalm βœ— 1 issues
Code Style βœ“ 0 files need formatting
Security βœ“ 0 vulnerabilities
Artifacts
  • test-results.xml - JUnit test results
  • phpstan.json - PHPStan analysis
  • psalm.json / psalm.sarif - Psalm analysis
  • pint.json - Code style report
  • audit.json - Security audit

Generated by core php qa pipeline

Removes `2>&1` redirection from Psalm commands in the QA workflow.
This prevents stderr output (like progress bars and platform warnings)
from contaminating the JSON and SARIF output files, which caused
"Invalid SARIF" errors in the upload step.
Upgrades `github/codeql-action/upload-sarif` from v3 to v4.
This resolves an issue where v3 rejects Psalm's SARIF output due to location values of 0 (invalid under strict schema validation), which v4 handles more gracefully.
Patches the SARIF file generated by Psalm to replace invalid line/column numbers (0) with 1.
This satisfies the strict schema validation required by the `github/codeql-action/upload-sarif` action.
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.

2 participants