Skip to content

Conversation

@ebinnion
Copy link
Contributor

@ebinnion ebinnion commented Dec 15, 2025

Changes proposed in this Pull Request:

This PR adds the WordPress environment type (wp_get_environment_type()) to the WooCommerce System Status Report. The environment type indicates whether a site is configured as production, staging, development, or local.

Changes:

  • Added wp_environment_type to the REST API schema and data collection in class-wc-rest-system-status-v2-controller.php
  • Added "Environment type" row to the WordPress Environment section of the status report UI
  • Updated tests to account for the new field

How to test the changes in this Pull Request:

  1. Navigate to WooCommerce → Status in the WordPress admin
  2. In the "WordPress environment" section, verify a new row "Environment type" appears (after "WordPress cron" and before "Language")
  3. The value should display one of: production, staging, development, or local based on your WP_ENVIRONMENT_TYPE constant
  4. Click "Get system report" and verify the "WP Environment Type" field appears in the exported text
  5. Test the REST API: GET /wp-json/wc/v3/system_status and verify environment.wp_environment_type is present in the response. You can do this by creating an API key and then calling curl -s -u "CONSUMER_KEY:CONSUMER_SECRET" "https://example.com/wp-json/wc/v3/system_status?_fields=environment"

Testing that has already taken place:

Unit tests are passing and manual testing as described above.

Milestone

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch

Type

  • Add - Adds functionality

Message

Add WordPress environment type to site status report.

Adds wp_get_environment_type() value to the WordPress Environment
section of the WooCommerce system status report. This helps identify
whether a site is configured as production, staging, development,
or local.
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Dec 15, 2025
@ebinnion ebinnion self-assigned this Dec 15, 2025
@ebinnion ebinnion marked this pull request as ready for review December 15, 2025 21:25
@ebinnion ebinnion added this to the 10.5.0 milestone Dec 15, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

📝 Walkthrough

Walkthrough

Adds WordPress environment type reporting: a changelog entry, a new "Environment type" row in the admin status report, a wp_environment_type field in the REST system status schema and payload, and updated unit tests to assert the new field.

Changes

Cohort / File(s) Summary
Changelog
plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr
New changelog entry (patch) documenting addition of WordPress environment type to site status report.
Status Report Display
plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
Adds an "Environment type" row to the WordPress environment section; displays value from $environment['wp_environment_type'] with a help tip.
REST API System Status
plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
Adds wp_environment_type to the environment schema and populates it via wp_get_environment_type() in the system status response.
Unit Tests
plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php, plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
Updates test_get_system_status_info_environment to expect 35 environment items (was 34) and asserts environment['wp_environment_type'] equals wp_get_environment_type().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review REST schema addition and readonly/view context flags in class-wc-rest-system-status-v2-controller.php.
  • Verify the admin view displays the value safely (escaping/formatting) in html-admin-page-status-report.php.
  • Confirm both unit tests correctly assert the new field and array size adjustments.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: adding WordPress environment type to the site status report, which aligns with the primary objective of the changeset.
Description check ✅ Passed The PR description provides detailed information about the changes, testing instructions, and affected components, all directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 update/add-wp-environment-to-ssr

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

🧹 Nitpick comments (2)
plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php (1)

129-129: Consider a more resilient assertion approach.

While updating the count is necessary for this change, consider refactoring this test to be more resilient to future additions. Instead of asserting an exact count (which breaks every time a field is added), consider asserting that specific expected keys exist.

For example:

-		$this->assertEquals( 35, count( $environment ) );
+		// Verify key environment fields are present
+		$this->assertArrayHasKey( 'wp_environment_type', $environment );
+		$this->assertArrayHasKey( 'wp_version', $environment );
+		$this->assertArrayHasKey( 'wp_cron', $environment );

This approach tests the interface rather than implementation details, making tests more maintainable. Based on learnings, ...

plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php (1)

122-122: Consider a more resilient assertion approach.

While updating the count is necessary for this change, consider refactoring this test to be more resilient to future additions. Instead of asserting an exact count (which breaks every time a field is added), consider asserting that specific expected keys exist.

For example:

-		$this->assertEquals( 35, count( $environment ) );
+		// Verify key environment fields are present
+		$this->assertArrayHasKey( 'wp_environment_type', $environment );
+		$this->assertArrayHasKey( 'wp_version', $environment );
+		$this->assertArrayHasKey( 'wp_cron', $environment );

This approach tests the interface rather than implementation details, making tests more maintainable. Based on learnings, ...

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 953c595 and ae60d0c.

📒 Files selected for processing (5)
  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr (1 hunks)
  • plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php (1 hunks)
  • plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php (2 hunks)
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php (1 hunks)
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{php,js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/avoid-regex.mdc)

**/*.{php,js,jsx,ts,tsx}: Avoid regular expressions in favor of more readable and maintainable alternatives, only using regex when no built-in alternative exists, performance is critical, the pattern is complex and well-documented, or maintaining legacy code
Document regular expressions extensively by explaining what the pattern matches, using named groups to improve readability, and adding comprehensive tests for edge cases and security issues
Validate regex input first and consider security implications such as ReDoS (Regular Expression Denial of Service) attacks and injection vulnerabilities when using regular expressions

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
  • plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
**/*.{php,js,jsx,tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/code-quality.mdc)

**/*.{php,js,jsx,tsx,ts}: Guard all code against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Ensure code is readable and intuitive
Add unit or E2E tests where applicable

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
  • plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
plugins/woocommerce/tests/**/*.php

📄 CodeRabbit inference engine (.cursor/rules/woo-phpunit.mdc)

plugins/woocommerce/tests/**/*.php: All setUp() and tearDown() methods in WooCommerce PHPUnit test classes must be declared as public, not protected
All test methods in WooCommerce PHPUnit tests must be declared as public, not protected
Add declare( strict_types = 1 ); at the top of WooCommerce PHPUnit test files
WooCommerce PHPUnit test classes should extend WC_Unit_Test_Case and include proper class documentation

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
**/*.{php,js,ts,jsx,tsx}

⚙️ CodeRabbit configuration file

**/*.{php,js,ts,jsx,tsx}: Don't trust that extension developers will follow the best practices, make sure the code:

  • Guards against unexpected inputs.
  • Sanitizes and validates any potentially dangerous inputs.
  • Is backwards compatible.
  • Is readable and intuitive.
  • Has unit or E2E tests where applicable.
    When making any changes to code that deletes or modifies orders/products/customer data, make sure that there are
    sufficient checks in place to prevent accidental data loss. As an example, if deleting a draft order, check that
    the order status is indeed draft or checkout-draft. Also think about whether race conditions could occur and
    delete orders that don't belong to the current customer. When in doubt, ask for clarification in the PR comments.

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
  • plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
plugins/woocommerce/includes/**/*.php

📄 CodeRabbit inference engine (CLAUDE.md)

Legacy WordPress code in includes/ directory should be modified minimally and only when necessary

Files:

  • plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
  • plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: packages/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:12:58.709Z
Learning: Applies to packages/js/**/changelog/* : Changelog entry format: Include Type field with values `fix`, `add`, `update`, `dev`, `tweak`, `performance`, or `enhancement` to categorize the change
📚 Learning: 2025-11-24T16:12:58.709Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: packages/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:12:58.709Z
Learning: Applies to packages/js/**/*.{js,ts,tsx} : Add a changelog entry for every functional change to a WooCommerce JS package using `pnpm changelog add` or manual creation in `packages/js/[package-name]/changelog/[type-brief-description]`

Applied to files:

  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr
📚 Learning: 2025-07-15T15:39:21.856Z
Learnt from: jorgeatorres
Repo: woocommerce/woocommerce PR: 59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.

Applied to files:

  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr
📚 Learning: 2025-08-22T10:00:26.594Z
Learnt from: jorgeatorres
Repo: woocommerce/woocommerce PR: 60555
File: tools/monorepo-utils/src/code-freeze/commands/changelog/lib/index.ts:0-0
Timestamp: 2025-08-22T10:00:26.594Z
Learning: In WooCommerce workflows, the version variable used in changelog generation is guaranteed to be in X.Y.Z[-suffix] format because it comes from the plugin version itself via the $VERSION environment variable, making defensive programming for X.Y inputs unnecessary in tools/monorepo-utils/src/code-freeze/commands/changelog/lib/index.ts.

Applied to files:

  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr
📚 Learning: 2025-11-24T16:12:58.709Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: packages/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:12:58.709Z
Learning: Applies to packages/js/data/src/** : For woocommerce/data package changes, update in this order: (1) Types in `src/[module]/types.ts`, (2) Test stubs in `src/[module]/test/helpers/`, (3) Implementation, (4) Add changelog entry

Applied to files:

  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use resilient assertions that won't break when adjacent code changes or new keys are added to data structures

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
📚 Learning: 2025-11-11T11:03:44.571Z
Learnt from: opr
Repo: woocommerce/woocommerce PR: 61507
File: plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version4/Customers/class-wc-rest-customers-v4-controller-tests.php:638-638
Timestamp: 2025-11-11T11:03:44.571Z
Learning: In WooCommerce test files (plugins/woocommerce/tests/**/*.php), prefer explicit count assertions over scoping tests with parameters like `include` when testing pagination and default behaviors. Explicit counts test the specifics more reliably and help catch edge cases.

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Test behavior and interfaces, not implementation details, to ensure tests remain resilient when internal code changes

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use targeted assertions instead of full equality checks - break down array comparisons into individual assertions using assertArrayHasKey() and specific value assertions

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*IntegrationTest.php : For REST API endpoint tests, use wp_set_current_user(), WP_REST_Request, and rest_do_request() to test endpoints, verifying status codes and response structure

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use assertSame() for strict === comparisons, assertEquals() for loose == comparisons, assertNull() for null checks, assertTrue() for booleans, assertArrayHasKey() to check key existence, assertIsArray() for type checks, and assertCount() for array size

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
📚 Learning: 2025-12-12T11:54:25.185Z
Learnt from: mikejolley
Repo: woocommerce/woocommerce PR: 62393
File: plugins/woocommerce/includes/class-wc-cart.php:1626-1635
Timestamp: 2025-12-12T11:54:25.185Z
Learning: In the WooCommerce plugin file plugins/woocommerce/includes/class-wc-cart.php (and related shipping code), keep package_id as a union type that accepts both int and string values to preserve backward compatibility with the REST API schema. Document that strict_types environments may raise TypeError if only strings are accepted, and consider testing REST payloads with mixed types. Do not convert to a strict string type; if downstream code relies on string methods, normalize at the boundary (e.g., coerce when reading from API) but do not change the API schema behavior.

Applied to files:

  • plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
  • plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
🧬 Code graph analysis (1)
plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php (1)
plugins/woocommerce/includes/wc-core-functions.php (1)
  • wc_help_tip (1679-1701)
⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (4)
plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr (1)

1-4: LGTM!

The changelog entry follows the correct format with appropriate significance (patch) and type (add) values.

plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php (2)

209-214: LGTM!

The schema definition for wp_environment_type is correctly structured with appropriate type, context, and readonly settings.


1016-1016: No action needed. wp_get_environment_type() is supported.

WooCommerce requires WordPress 6.7 as the minimum version, which is far newer than WordPress 5.5 where wp_get_environment_type() was introduced. The function is guaranteed to be available in all supported WordPress versions, so no function_exists check or fallback is required.

Likely an incorrect or invalid review comment.

plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php (1)

224-228: LGTM!

The new environment type row is properly implemented with:

  • Correct escaping using esc_html()
  • Appropriate help tip explaining the field
  • Consistent data-export-label for the export functionality
  • Proper positioning in the WordPress environment section

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

@ebinnion ebinnion force-pushed the update/add-wp-environment-to-ssr branch from ae60d0c to acd3496 Compare December 15, 2025 22:06
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php (1)

1-7: Add missing declare( strict_types = 1 ); declaration.

As per coding guidelines, all WooCommerce PHPUnit test files should include a strict types declaration at the top.

Apply this diff to add the declaration:

 <?php
+declare( strict_types = 1 );
+
 /**
  * Class WC_Tests_REST_System_Status file.
  *
  * @package Automattic/WooCommerce/Tests
  */

Based on coding guidelines for plugins/woocommerce/tests/**/*.php.

🧹 Nitpick comments (2)
plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php (2)

129-129: Consider asserting key existence instead of exact count.

The exact count assertion will break whenever environment fields are added or removed. Per learnings, prefer resilient assertions that test specific expectations rather than brittle counts.

Consider replacing the count assertion with explicit key existence checks:

-		$this->assertEquals( 35, count( $environment ) );
+		$this->assertArrayHasKey( 'wp_environment_type', $environment );

The existing assertions already verify specific keys (lines 132-137), making the count check somewhat redundant.

Based on learnings about resilient test assertions.


137-137: Prefer assertSame() for strict type checking.

Since wp_get_environment_type() returns a string, use assertSame() for strict === comparison instead of assertEquals() which uses loose == comparison.

Apply this diff:

-		$this->assertEquals( wp_get_environment_type(), $environment['wp_environment_type'] );
+		$this->assertSame( wp_get_environment_type(), $environment['wp_environment_type'] );

Based on learnings about using assertSame() for strict comparisons.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae60d0c and acd3496.

📒 Files selected for processing (3)
  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr (1 hunks)
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php (1 hunks)
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{php,js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/avoid-regex.mdc)

**/*.{php,js,jsx,ts,tsx}: Avoid regular expressions in favor of more readable and maintainable alternatives, only using regex when no built-in alternative exists, performance is critical, the pattern is complex and well-documented, or maintaining legacy code
Document regular expressions extensively by explaining what the pattern matches, using named groups to improve readability, and adding comprehensive tests for edge cases and security issues
Validate regex input first and consider security implications such as ReDoS (Regular Expression Denial of Service) attacks and injection vulnerabilities when using regular expressions

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
**/*.{php,js,jsx,tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/code-quality.mdc)

**/*.{php,js,jsx,tsx,ts}: Guard all code against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Ensure code is readable and intuitive
Add unit or E2E tests where applicable

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
plugins/woocommerce/tests/**/*.php

📄 CodeRabbit inference engine (.cursor/rules/woo-phpunit.mdc)

plugins/woocommerce/tests/**/*.php: All setUp() and tearDown() methods in WooCommerce PHPUnit test classes must be declared as public, not protected
All test methods in WooCommerce PHPUnit tests must be declared as public, not protected
Add declare( strict_types = 1 ); at the top of WooCommerce PHPUnit test files
WooCommerce PHPUnit test classes should extend WC_Unit_Test_Case and include proper class documentation

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
**/*.{php,js,ts,jsx,tsx}

⚙️ CodeRabbit configuration file

**/*.{php,js,ts,jsx,tsx}: Don't trust that extension developers will follow the best practices, make sure the code:

  • Guards against unexpected inputs.
  • Sanitizes and validates any potentially dangerous inputs.
  • Is backwards compatible.
  • Is readable and intuitive.
  • Has unit or E2E tests where applicable.
    When making any changes to code that deletes or modifies orders/products/customer data, make sure that there are
    sufficient checks in place to prevent accidental data loss. As an example, if deleting a draft order, check that
    the order status is indeed draft or checkout-draft. Also think about whether race conditions could occur and
    delete orders that don't belong to the current customer. When in doubt, ask for clarification in the PR comments.

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
🧠 Learnings (9)
📚 Learning: 2025-11-24T16:12:58.709Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: packages/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:12:58.709Z
Learning: Applies to packages/js/**/*.{js,ts,tsx} : Add a changelog entry for every functional change to a WooCommerce JS package using `pnpm changelog add` or manual creation in `packages/js/[package-name]/changelog/[type-brief-description]`

Applied to files:

  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr
📚 Learning: 2025-07-15T15:39:21.856Z
Learnt from: jorgeatorres
Repo: woocommerce/woocommerce PR: 59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.

Applied to files:

  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr
📚 Learning: 2025-11-24T16:12:58.709Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: packages/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:12:58.709Z
Learning: Applies to packages/js/data/src/** : For woocommerce/data package changes, update in this order: (1) Types in `src/[module]/types.ts`, (2) Test stubs in `src/[module]/test/helpers/`, (3) Implementation, (4) Add changelog entry

Applied to files:

  • plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use resilient assertions that won't break when adjacent code changes or new keys are added to data structures

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Test behavior and interfaces, not implementation details, to ensure tests remain resilient when internal code changes

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*IntegrationTest.php : For REST API endpoint tests, use wp_set_current_user(), WP_REST_Request, and rest_do_request() to test endpoints, verifying status codes and response structure

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
📚 Learning: 2025-11-11T11:03:44.571Z
Learnt from: opr
Repo: woocommerce/woocommerce PR: 61507
File: plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version4/Customers/class-wc-rest-customers-v4-controller-tests.php:638-638
Timestamp: 2025-11-11T11:03:44.571Z
Learning: In WooCommerce test files (plugins/woocommerce/tests/**/*.php), prefer explicit count assertions over scoping tests with parameters like `include` when testing pagination and default behaviors. Explicit counts test the specifics more reliably and help catch edge cases.

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use targeted assertions instead of full equality checks - break down array comparisons into individual assertions using assertArrayHasKey() and specific value assertions

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use assertSame() for strict === comparisons, assertEquals() for loose == comparisons, assertNull() for null checks, assertTrue() for booleans, assertArrayHasKey() to check key existence, assertIsArray() for type checks, and assertCount() for array size

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
⏰ 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). (27)
  • GitHub Check: Blocks e2e tests - Legacy MiniCart 2/3 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests - Legacy MiniCart 3/3 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 6/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 5/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 7/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests - Legacy MiniCart - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 1/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 2/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 1/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 3/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core API tests - @woocommerce/plugin-woocommerce [api]
  • GitHub Check: Core e2e tests 6/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 5/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 4/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Metrics - @woocommerce/plugin-woocommerce [performance]
  • GitHub Check: PHP: 8.4 WP: latest (HPOS:off) [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.8.3] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: PHP: 8.4 WP: latest [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: PHP: 8.4 WP: latest - Legacy MiniCart [WP latest] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Core e2e tests 3/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: PHP: 8.4 WP: latest - Legacy MiniCart [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: PHP: 8.4 WP: latest [WP latest] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Lint - @woocommerce/plugin-woocommerce
  • GitHub Check: PHPStan Analysis
  • GitHub Check: build
  • GitHub Check: Add changelog to PR
🔇 Additional comments (1)
plugins/woocommerce/changelog/62458-update-add-wp-environment-to-ssr (1)

1-4: LGTM!

The changelog entry follows the correct format with appropriate significance (patch) and type (add) for this feature addition.

@ebinnion ebinnion requested a review from a team December 16, 2025 15:25
@github-actions
Copy link
Contributor

Testing Guidelines

Hi @woocommerce/moltres,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

🤖 Backwards Compatibility Review - Found 2 potential issues

Generated by Claude via this workflow run

Copy link
Contributor

@rtio rtio left a comment

Choose a reason for hiding this comment

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

Code looks fine, testing in a bit

Copy link
Contributor

@rtio rtio left a comment

Choose a reason for hiding this comment

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

WordPress Environment Section
Image

System report
Image

API call
Image

Testing a different env
Image

@ebinnion ebinnion merged commit c84f147 into trunk Dec 17, 2025
50 checks passed
@ebinnion ebinnion deleted the update/add-wp-environment-to-ssr branch December 17, 2025 22:13
@github-actions
Copy link
Contributor

⚠️ API Documentation Reminder

Hi @ebinnion! Your PR contains REST API changes. Please consider updating the REST API documentation if your changes affect the public API.

Changed API files:

plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php

ebinnion added a commit to woocommerce/woocommerce-rest-api-docs that referenced this pull request Dec 17, 2025
Document the new wp_environment_type field added to the System Status
REST API endpoint in woocommerce/woocommerce#62458.

This field returns the WordPress environment type (production, staging,
development, or local) from wp_get_environment_type().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants