Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required code for Stripe redirect in new tab fix #2014

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

truongwp
Copy link
Contributor

@truongwp truongwp commented Oct 1, 2024

This makes something public.

Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

Walkthrough

The changes involve modifications to the visibility of a static variable and a method within the FrmFormsController class. The static variable $redirected_in_new_tab has been changed from private to public, and a method previously marked as private, print_open_in_new_tab_js_with_fallback_handler, is now public. These changes allow for greater accessibility of these elements from outside the class.

Changes

File Change Summary
classes/controllers/FrmFormsController.php - Changed visibility of $redirected_in_new_tab from private to public.
- Changed visibility of print_open_in_new_tab_js_with_fallback_handler from private to public.

Possibly related PRs

Suggested labels

run analysis, run tests


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 175d44a and 3817167.

📒 Files selected for processing (1)
  • classes/controllers/FrmFormsController.php (2 hunks)
🔇 Additional comments (2)
classes/controllers/FrmFormsController.php (2)

13-17: LGTM: Variable visibility change is properly documented.

The change from private to public visibility for $redirected_in_new_tab is well documented with a version tag in the docblock comment.


2742-2747: LGTM: Method visibility change is properly documented.

The change from private to public visibility for print_open_in_new_tab_js_with_fallback_handler is well documented with a version tag in the docblock comment. This change aligns with the related variable visibility change above.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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
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: 0

🧹 Outside diff range and nitpick comments (3)
classes/controllers/FrmFormsController.php (3)

Line range hint 2742-2757: Function visibility changed to public.

The print_open_in_new_tab_js_with_fallback_handler function has been made public. While this change may be intentional to allow external access, it's important to consider the implications:

  1. Increased exposure of internal functionality.
  2. Potential security risks if the function is not meant to be called directly from outside the class.
  3. Backwards compatibility concerns if this was previously used as a private method.

Ensure that this change aligns with the intended use of the function and doesn't introduce any security vulnerabilities.


Line range hint 2742-2757: Consider improving JavaScript handling and security.

While the function achieves its purpose, there are several areas for potential improvement:

  1. Inline JavaScript: Consider moving the JavaScript to a separate file and enqueuing it properly. This adheres to best practices and improves security.

  2. Global variable usage: The frmShowNewTabFallback global variable could potentially conflict with other scripts. Consider using a namespace or a more specific variable name.

  3. No fallback for disabled JavaScript: The function doesn't handle cases where JavaScript is disabled in the browser. Consider adding a noscript fallback.

  4. Error handling: The function could benefit from more robust error handling and user feedback mechanisms.

Example improvement:

public static function print_open_in_new_tab_js_with_fallback_handler( $success_url, $args ) {
    $fallback_data = array(
        'formId'  => intval( $args['form']->id ),
        'message' => self::get_redirect_fallback_message( $success_url, $args ),
    );
    wp_localize_script( 'frm-new-tab-handler', 'frmNewTabData', $fallback_data );
    
    echo '<a href="' . esc_url( $success_url ) . '" target="_blank" class="frm-new-tab-link">' . esc_html__( 'Click here if not redirected', 'formidable' ) . '</a>';
    echo '<noscript><meta http-equiv="refresh" content="0;url=' . esc_url( $success_url ) . '"></noscript>';
}

This suggestion separates concerns, improves security, and provides a fallback for users with JavaScript disabled.


Line range hint 1-3019: Overall file review: FrmFormsController.php

This file contains the FrmFormsController class, which appears to be a core component of the Formidable Forms plugin. While the main change reviewed was the print_open_in_new_tab_js_with_fallback_handler function, it's important to note:

  1. Code Complexity: The file is quite large and complex. Consider breaking it down into smaller, more manageable classes or modules to improve maintainability.

  2. Deprecated Methods: There are deprecated methods at the end of the file. Consider removing these in future versions to clean up the codebase.

  3. Security: Ensure that all user inputs are properly sanitized and validated throughout the file, especially in form submission handling.

  4. Performance: Given the complexity of the class, it might be worth profiling to identify any performance bottlenecks, especially in form processing methods.

  5. Documentation: While there are some inline comments, the file could benefit from more comprehensive documentation, especially for complex methods.

  6. Testing: Ensure that unit tests cover the changed functionality, particularly the new public method.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cdf8ec1 and 175d44a.

📒 Files selected for processing (1)
  • classes/controllers/FrmFormsController.php (2 hunks)

Copy link
Contributor

@Crabcyborg Crabcyborg left a comment

Choose a reason for hiding this comment

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

Thanks @truongwp!

I'll go ahead and merge this so it isn't blocking the other update.

🚀

@Crabcyborg Crabcyborg modified the milestones: 6.16.1, 6.16.2 Nov 11, 2024
@Crabcyborg Crabcyborg modified the milestones: 6.16.2, 6.16.3 Nov 20, 2024
@Crabcyborg Crabcyborg modified the milestones: 6.16.3, 6.17 Dec 10, 2024
@Crabcyborg Crabcyborg modified the milestones: 6.17, 6.17.1 Jan 14, 2025
@Crabcyborg Crabcyborg modified the milestones: 6.18, 6.19 Feb 10, 2025
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