Skip to content

Guard plugin action links pro check when EDAC_KEY_VALID is undefined#1408

Merged
SteveJonesDev merged 3 commits intodevelopfrom
codex/fix-plugin-action-links-edac-key-guard
Mar 18, 2026
Merged

Guard plugin action links pro check when EDAC_KEY_VALID is undefined#1408
SteveJonesDev merged 3 commits intodevelopfrom
codex/fix-plugin-action-links-edac-key-guard

Conversation

@SteveJonesDev
Copy link
Copy Markdown
Member

@SteveJonesDev SteveJonesDev commented Feb 14, 2026

Summary

  • replace direct EDAC_KEY_VALID usage in plugin action links with edac_is_pro() guard
  • add a regression test that runs in a separate process and verifies Get Pro link behavior when EDAC_KEY_VALID is undefined

Root Cause

Plugin_Action_Links::add_plugin_action_links() referenced EDAC_KEY_VALID directly. In free-plugin contexts where the constant is not defined, PHP 8 raises an undefined constant error.

Test Added

  • tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php
    • test_add_plugin_action_links_adds_pro_link_when_key_constant_missing

Risk Assessment

Low risk. The change narrows to pro-state detection in one UI link condition and reuses existing helper logic (edac_is_pro()) already used elsewhere.

Environment Limitations

  • npm run lint:js:fix and npm run lint:js completed successfully.
  • npm run lint:php:fix and npm run lint:php could not run because vendor/bin/phpcbf and vendor/bin/phpcs are missing after incomplete Composer install.
  • npm run test:php is blocked by Docker socket permission in this sandbox (operation not permitted).
  • Earlier composer install failed due DNS resolution for api.github.com, preventing full PHP tooling install.

Summary by CodeRabbit

  • Tests

    • Added a unit test to ensure the “Get Pro” action appears when license-key validation is missing.
  • Refactor

    • Simplified Pro-status detection to use a dedicated helper, which changes when the “Get Pro” link is displayed.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @SteveJonesDev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a PHP 8 compatibility issue by addressing an Undefined constant error that occurred when EDAC_KEY_VALID was referenced in free-plugin environments. The change refactors the conditional logic for displaying the 'Get Pro' link in the plugin action links to use a robust helper function, edac_is_pro(), ensuring consistent and error-free behavior. A dedicated test has been introduced to validate this fix.

Highlights

  • PHP 8 Compatibility Fix: Replaced direct usage of the EDAC_KEY_VALID constant with the edac_is_pro() helper function in plugin action links to prevent PHP 8 undefined constant errors in free-plugin contexts.
  • New Regression Test: Added a new PHPUnit regression test (PluginActionLinksUndefinedKeyTest.php) to specifically verify that the 'Get Pro' link is correctly displayed when the EDAC_KEY_VALID constant is not defined.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • admin/class-plugin-action-links.php
    • Updated the condition for displaying the 'Get Pro' link to use edac_is_pro() instead of directly checking EDAC_KEY_VALID.
  • tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php
    • Added a new PHPUnit test file to verify the 'Get Pro' link is correctly displayed when the EDAC_KEY_VALID constant is not defined.
Activity
  • The author identified a root cause where Plugin_Action_Links::add_plugin_action_links() referenced EDAC_KEY_VALID directly, causing PHP 8 errors in free-plugin contexts.
  • A new regression test was added to ensure the 'Get Pro' link behavior is correct when EDAC_KEY_VALID is undefined, running in a separate process.
  • The author noted environment limitations during development, including incomplete Composer install due to DNS resolution issues, and blocked PHP tests due to Docker socket permissions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

This change replaces the direct constant/flag Pro check with the edac_is_pro() helper in plugin action link logic and adds a PHPUnit test that verifies a Pro link is added when the EDAC_KEY_VALID constant is not defined.

Changes

Cohort / File(s) Summary
Pro Status Validation Refactor
admin/class-plugin-action-links.php
Replaced the compound check (`! defined( 'EDACP_VERSION' )
Test Coverage for Undefined Key Scenario
tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php
Added PHPUnit test PluginActionLinksUndefinedKeyTest::test_add_plugin_action_links_adds_pro_link_when_key_constant_missing() (separate process) to assert a Pro link is added when EDAC_KEY_VALID is not defined.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • pattonwebz

Poem

🐰 I swapped the checks to one neat call,
A test hops in to catch the fall,
When keys are absent, the Pro link springs,
Little changes, but joyful things — 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing direct EDAC_KEY_VALID usage with edac_is_pro() guard in the plugin action links check.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-plugin-action-links-edac-key-guard
📝 Coding Plan
  • Generate coding plan for human review comments

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

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves a PHP 8 error caused by referencing an undefined constant. The fix correctly replaces the direct constant check with the edac_is_pro() helper function, which is a safer and more robust approach. The addition of a new regression test in a separate process is excellent, as it specifically verifies the fix for the undefined constant scenario. I have one suggestion to improve the mock function in the new test file to make it more accurate and maintainable.

Comment thread tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php`:
- Around line 21-24: The test method
test_add_plugin_action_links_adds_pro_link_when_key_constant_missing should
explicitly assert/guard the precondition that EDAC_KEY_VALID is undefined and
EDACP_VERSION is not set so edac_is_pro() takes the “key missing” branch; update
the test to check for and unset (or skip if defined) EDAC_KEY_VALID and
EDACP_VERSION before running the assertions (and mark the test skipped if the
environment cannot be coerced), and apply the same explicit precondition
handling to the other related test(s) that exercise the undefined-key branch
(referencing edac_is_pro and EDAC_KEY_VALID/EDACP_VERSION to locate the code).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cc7c1576-0d6c-4da7-ad92-ab2ff2283b1c

📥 Commits

Reviewing files that changed from the base of the PR and between dba204c and 6ef4bb0.

📒 Files selected for processing (1)
  • tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php

Comment thread tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php
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.

🧹 Nitpick comments (1)
tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php (1)

54-58: Consider tightening the regression assertion to validate link content.

Line 58 confirms the go_pro key exists; adding a content assertion would make the test more specific to the “Get Pro” behavior.

As per coding guidelines: tests/phpunit/**/*.php: Write unit tests for new PHP functions and classes in /tests/phpunit directory using PHPUnit.

Optional assertion hardening
 		$this->assertArrayHasKey( 'go_pro', $result, 'Pro link should be present when EDAC_KEY_VALID is undefined' );
+		$this->assertStringContainsString( 'Get Pro', $result['go_pro'] );
+		$this->assertStringContainsString( 'equalizedigital.com/accessibility-checker/pricing/', $result['go_pro'] );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php` around lines 54 -
58, The test currently only asserts the presence of the 'go_pro' key; tighten it
by also asserting the link content returned by
Plugin_Action_Links::add_plugin_action_links contains the expected “Get Pro”
anchor (or specific href/text you expect) to ensure the correct pro link is
rendered when EDAC_KEY_VALID is undefined. Find the Plugin_Action_Links instance
in Admin/PluginActionLinksUndefinedKeyTest and add an assertion like asserting
the $result['go_pro'] string contains the expected anchor text or URL (e.g.,
'Get Pro' or the pro link path) so the test validates both key presence and
correct link content.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php`:
- Around line 54-58: The test currently only asserts the presence of the
'go_pro' key; tighten it by also asserting the link content returned by
Plugin_Action_Links::add_plugin_action_links contains the expected “Get Pro”
anchor (or specific href/text you expect) to ensure the correct pro link is
rendered when EDAC_KEY_VALID is undefined. Find the Plugin_Action_Links instance
in Admin/PluginActionLinksUndefinedKeyTest and add an assertion like asserting
the $result['go_pro'] string contains the expected anchor text or URL (e.g.,
'Get Pro' or the pro link path) so the test validates both key presence and
correct link content.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7e02e1bd-3dfe-48de-a077-376416508376

📥 Commits

Reviewing files that changed from the base of the PR and between 6ef4bb0 and 286e8c6.

📒 Files selected for processing (1)
  • tests/phpunit/Admin/PluginActionLinksUndefinedKeyTest.php

@SteveJonesDev SteveJonesDev merged commit 4e36584 into develop Mar 18, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant