Skip to content

Pull medium from link if query arg is not set#2606

Merged
Crabcyborg merged 1 commit into
masterfrom
pull_medium_from_link_if_query_arg_is_not_set
Nov 27, 2025
Merged

Pull medium from link if query arg is not set#2606
Crabcyborg merged 1 commit into
masterfrom
pull_medium_from_link_if_query_arg_is_not_set

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Nov 27, 2025

Related PR #2601

This fixes an issue with new upsells links including utm_medium, so it's not set when we try to add a license.

Causing this warning.

PHP Warning: Undefined array key "utm_medium" in .../wp-content/plugins/formidable/classes/helpers/FrmAppHelper.php on line 176

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 27, 2025

Walkthrough

The FrmAppHelper.php file was updated to enhance UTM license handling. The maybe_add_utm_license() method now accepts an additional $link parameter, allowing it to derive the UTM medium from the link when not present in query arguments. A new private helper pull_medium_from_link() extracts the utm_medium value from URL query strings, supporting dynamic license type detection.

Changes

Cohort / File(s) Summary
UTM License Handling
classes/helpers/FrmAppHelper.php
Updated maybe_add_utm_license() signature to accept $link parameter; added logic to prefer $query_args['utm_medium'] or derive it from the link; added conditional utm_license assignment when medium is 'pro'. Updated maybe_add_missing_utm() to pass CTA link as second argument. Added new private static helper pull_medium_from_link() to extract utm_medium from URL query strings. Updated docblock for new parameter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Parameter addition: Verify that all call sites of maybe_add_utm_license() pass the $link argument correctly
  • URL parsing logic: Review the pull_medium_from_link() implementation to ensure proper query string extraction and edge case handling
  • Conditional logic: Confirm the precedence of utm_medium resolution (query_args first, then link) aligns with intended behavior

Possibly related PRs

  • Update pro tips and support sale api #2340: Modifies UTM-handling infrastructure in the same file; the previous PR added maybe_add_missing_utm() which is now updated to pass the CTA link to the enhanced maybe_add_utm_license() function.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: pulling the medium from a link when it's not already in query arguments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the issue being fixed and the rationale for the changes.
✨ 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 pull_medium_from_link_if_query_arg_is_not_set

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.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 006d247 and a08465b.

📒 Files selected for processing (1)
  • classes/helpers/FrmAppHelper.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
classes/helpers/FrmAppHelper.php (1)
stubs.php (2)
  • FrmProAddonsController (128-163)
  • get_readable_license_type (161-162)
⏰ 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). (6)
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP trunk
  • 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
🔇 Additional comments (2)
classes/helpers/FrmAppHelper.php (2)

172-188: LGTM! The enhanced logic correctly addresses the PR objective.

The updated maybe_add_utm_license() method now intelligently determines the UTM medium by first checking $query_args and falling back to extracting it from the provided link. This ensures the license parameter is added correctly even when the medium is only present in the link URL. The backward compatibility is maintained through the default parameter value.


266-266: Perfect! The updated call completes the PR objective.

Passing $cta_link as the second argument enables maybe_add_utm_license() to extract the medium from the link when it's not present in $query_args. This correctly addresses the issue where new upsell links with utm_medium in the URL weren't being processed properly for license tracking.

Comment thread classes/helpers/FrmAppHelper.php
@Crabcyborg Crabcyborg added this to the 6.26 milestone Nov 27, 2025
@Crabcyborg Crabcyborg merged commit aa0e68f into master Nov 27, 2025
34 of 38 checks passed
@Crabcyborg Crabcyborg deleted the pull_medium_from_link_if_query_arg_is_not_set branch November 27, 2025 13:28
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…ry_arg_is_not_set

Pull medium from link if query arg is not set
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.

1 participant