-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Add WordPress environment type to site status report #62458
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
Conversation
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.
📝 WalkthroughWalkthroughAdds WordPress environment type reporting: a changelog entry, a new "Environment type" row in the admin status report, a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
📒 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.phpplugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.phpplugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.phpplugins/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.phpplugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.phpplugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.phpplugins/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 aspublic, notprotected
All test methods in WooCommerce PHPUnit tests must be declared aspublic, notprotected
Adddeclare( strict_types = 1 );at the top of WooCommerce PHPUnit test files
WooCommerce PHPUnit test classes should extendWC_Unit_Test_Caseand include proper class documentation
Files:
plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.phpplugins/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 indeeddraftorcheckout-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.phpplugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.phpplugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.phpplugins/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.phpplugins/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.phpplugins/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.phpplugins/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.phpplugins/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.phpplugins/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.phpplugins/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.phpplugins/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.phpplugins/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_typeis 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
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. 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. |
ae60d0c to
acd3496
Compare
There was a problem hiding this 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 missingdeclare( 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: PreferassertSame()for strict type checking.Since
wp_get_environment_type()returns a string, useassertSame()for strict===comparison instead ofassertEquals()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
📒 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 aspublic, notprotected
All test methods in WooCommerce PHPUnit tests must be declared aspublic, notprotected
Adddeclare( strict_types = 1 );at the top of WooCommerce PHPUnit test files
WooCommerce PHPUnit test classes should extendWC_Unit_Test_Caseand 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 indeeddraftorcheckout-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.
Testing GuidelinesHi @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:
|
There was a problem hiding this 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
...ommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
Show resolved
Hide resolved
plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
Show resolved
Hide resolved
rtio
left a comment
There was a problem hiding this 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
rtio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
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: |
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().
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 asproduction,staging,development, orlocal.Changes:
wp_environment_typeto the REST API schema and data collection inclass-wc-rest-system-status-v2-controller.phpHow to test the changes in this Pull Request:
production,staging,development, orlocalbased on yourWP_ENVIRONMENT_TYPEconstantGET /wp-json/wc/v3/system_statusand verifyenvironment.wp_environment_typeis present in the response. You can do this by creating an API key and then callingcurl -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
Changelog Entry Details
Significance
Type
Message
Add WordPress environment type to site status report.