Skip to content

Conversation

@saifsultanc
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/3060866235/88730

Summary

Infinite recursion issue.

@coderabbitai
Copy link

coderabbitai bot commented Oct 23, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change adds a re-entrancy guard using a $calculating flag to prevent recursive calculation triggers during the recalculation flow in the date-time calculator, controlling when the input-value filter applies field-specific logic.

Changes

Cohort / File(s) Summary
Recalculation guard mechanism
gp-date-time-calculator/gpdtc-recalc.php
Added a local $calculating flag initialized to false and passed into the closure via use. Extended the input-value filter to check if not currently calculating and if the field ID matches the target field before bypassing non-target field logic. Implemented a guard sequence that sets the flag to true before triggering recalculation, builds form and entry context, then resets the flag to false before returning the GFCommon::calculate result.

Sequence Diagram

sequenceDiagram
    actor User
    participant Filter as Input Value Filter
    participant Guard as Calculation Guard
    participant Calc as GFCommon::calculate

    User->>Filter: Trigger calculation
    rect rgb(200, 220, 255)
        Note over Guard: $calculating = true
    end
    Filter->>Filter: Check $calculating flag
    Note over Filter: Skip recursive filter logic
    Guard->>Calc: Build form/entry context
    Calc->>Calc: Execute calculation
    rect rgb(200, 220, 255)
        Note over Guard: $calculating = false
    end
    Filter-->>User: Return result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • gravitywiz/snippet-library#1156: Implements a similar re-entrancy guard pattern using a static $processing array to prevent recursive processing in Gravity Forms filters.

Suggested reviewers

  • veryspry
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch saif/fix/88730-fix-infinite-recursion

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb06fa4 and 36b76d8.

📒 Files selected for processing (1)
  • gp-date-time-calculator/gpdtc-recalc.php (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

Warnings
⚠️ When ready, don't forget to request reviews on this pull request from your fellow wizards.

Generated by 🚫 dangerJS against 36b76d8

@saifsultanc saifsultanc merged commit 99b672c into master Oct 23, 2025
3 of 4 checks passed
@saifsultanc saifsultanc deleted the saif/fix/88730-fix-infinite-recursion branch October 23, 2025 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants