Skip to content

issue 5929 alternative fix#2482

Merged
Crabcyborg merged 5 commits into
masterfrom
issue_5929_alternative_fix
Aug 29, 2025
Merged

issue 5929 alternative fix#2482
Crabcyborg merged 5 commits into
masterfrom
issue_5929_alternative_fix

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Aug 29, 2025

Related PR #2456

Fixes https://github.com/Strategy11/formidable-pro/issues/5929

I don't love the list of hard coded keys. I think we really just want to check the prepared values instead of the other value.

I tried this out on Emma's QA site and it looks like it works well.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 29, 2025

Warning

Rate limit exceeded

@Crabcyborg has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 38 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 78396fd and 72dc845.

📒 Files selected for processing (1)
  • classes/helpers/FrmStylesHelper.php (4 hunks)

Walkthrough

Refactored FrmStylesHelper::output_vars to delegate CSS variable emission decisions to a new private helper should_add_css_var which prepares and validates values, compares against defaults, and provides a prepared value; output_vars now echoes the CSS var only when the helper permits.

Changes

Cohort / File(s) Summary
Styles Helper internals
classes/helpers/FrmStylesHelper.php
Extracted decision logic into private should_add_css_var($settings, $defaults, $var, &$prepared_value); it calls css_var_prepare_value to prepare a value, returns false if empty or equal to default, validates via css_value_is_valid, and returns a boolean while populating $prepared_value; output_vars now echoes the CSS var only when the helper returns true; added docblock; css_var_prepare_value now guards non-string/non-numeric values and returns the computed $value.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant StylesHelper as FrmStylesHelper
  participant Preparer as css_var_prepare_value
  participant Validator as css_value_is_valid

  Caller->>StylesHelper: output_vars(settings, defaults)
  loop each CSS variable
    StylesHelper->>Preparer: css_var_prepare_value(settings, var)
    Preparer-->>StylesHelper: prepared_value
    alt prepared_value empty
      StylesHelper-->>StylesHelper: skip output
    else if prepared_value == default
      StylesHelper-->>StylesHelper: skip output
    else
      StylesHelper->>Validator: css_value_is_valid(prepared_value)
      alt valid
        StylesHelper-->>Caller: echo "--var: prepared_value"
      else
        StylesHelper-->>StylesHelper: skip output
      end
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue_5929_alternative_fix

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
classes/helpers/FrmStylesHelper.php (1)

454-462: Docblock: clarify purpose, by-ref param, and finalize @SInCE before merge

Add a short summary, mark the by-reference param, and replace x.x with the release version.

Apply this diff:

-	/**
-	 * @since x.x
-	 *
-	 * @param array  $settings
-	 * @param array  $defaults
-	 * @param string $var
-	 * @param string $prepared_value
-	 * @return bool
-	 */
+	/**
+	 * Decide if a CSS custom property should be output and return the prepared value by reference.
+	 *
+	 * @since x.x
+	 *
+	 * @param array  $settings        Settings array for the current style.
+	 * @param array  $defaults        Default settings array for comparison.
+	 * @param string $var             The settings key / CSS variable name.
+	 * @param string &$prepared_value Prepared CSS value (output parameter).
+	 * @return bool                   True to output, false to skip.
+	 */
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4aa00d8 and 1c312b3.

📒 Files selected for processing (1)
  • classes/helpers/FrmStylesHelper.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Run PHP Syntax inspection (8.3)
  • GitHub Check: Cypress
🔇 Additional comments (1)
classes/helpers/FrmStylesHelper.php (1)

448-450: LGTM: cleaner call site and single source of truth for value prep

The refactor reduces duplication and centralizes validation. Echoing the prepped value only when permitted is correct.

Comment thread classes/helpers/FrmStylesHelper.php
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 27.35%. Comparing base (c39b7f1) to head (49d2448).
⚠️ Report is 111 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2482      +/-   ##
============================================
- Coverage     27.48%   27.35%   -0.13%     
- Complexity     8706     8710       +4     
============================================
  Files           140      140              
  Lines         28739    28750      +11     
============================================
- Hits           7898     7864      -34     
- Misses        20841    20886      +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@Liviu-p Liviu-p left a comment

Choose a reason for hiding this comment

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

Looks good to me @Crabcyborg, I can confirm that it fixes the issue reported by Emma as well.

@Crabcyborg
Copy link
Copy Markdown
Contributor Author

Thanks Liviu!

@Crabcyborg Crabcyborg merged commit 38b2f4c into master Aug 29, 2025
16 checks passed
@Crabcyborg Crabcyborg deleted the issue_5929_alternative_fix branch August 29, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants