Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 28, 2025

Adds PHP memory limit to wp cli info output for easier support diagnostics. Includes optional warning when memory limit is set below 512M.

Changes

  • Memory limit display: Added php_memory_limit field to both list and JSON output formats, positioned after PHP version
  • Low memory warning: Emits warning when limit < 512M (excluding unlimited/-1), with actionable remediation advice
  • Helper methods:
    • check_memory_limit(): Validates limit and triggers warnings
    • convert_to_bytes(): Parses memory strings (e.g., "256M", "1G") to bytes for threshold comparison
  • Tests: Added Behat scenarios for memory limit display and warning behavior

Example Output

$ wp cli info
PHP version:     8.5.0
PHP memory limit: 128M
php.ini used:    /etc/php/8.5/cli/php.ini
...
Warning: PHP memory limit is set to 128M. This may be too low for some WP-CLI operations. Consider increasing it to at least 512M or setting it to -1 (unlimited) for CLI usage.

$ wp cli info --format=json
{"php_version":"8.5.0","php_memory_limit":"128M",...}

No warning displayed when limit is -1 (unlimited) or >= 512M.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php tup_errors=0&#39; &#39;-d asp_tags=Off&#39; &#39;-d short_open_tag=Off&#39; &#39;-d error_reporting=E_ALL&#39; &#39;-n&#39; &#39;-l&#39; &#39;./git (dns block)
  • nosuchhost_asdf_asdf_asdf.com
    • Triggering command: /usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php tup_errors=0&#39; &#39;-d asp_tags=Off&#39; &#39;-d short_open_tag=Off&#39; &#39;-d error_reporting=E_ALL&#39; &#39;-n&#39; &#39;-l&#39; &#39;./git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Display memory limit in wp cli info</issue_title>
<issue_description>This would make dealing with support requests a biteasier.

Bonus: could emit a warning when we think the limit is too low (criteria TBD)</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@codecov
Copy link

codecov bot commented Dec 28, 2025

Codecov Report

❌ Patch coverage is 18.75000% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/commands/src/CLI_Command.php 18.75% 26 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI and others added 3 commits December 28, 2025 11:23
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add memory limit display in wp cli info Display PHP memory limit in wp cli info output Dec 28, 2025
Copilot AI requested a review from swissspidy December 28, 2025 11:31
@swissspidy swissspidy marked this pull request as ready for review January 5, 2026 09:28
@swissspidy swissspidy requested a review from a team as a code owner January 5, 2026 09:28
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.

Display memory limit in wp cli info

2 participants