Fix: Set WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT to unlimited (-1) when running WP-CLI#6126
Fix: Set WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT to unlimited (-1) when running WP-CLI#6126adityaanurag0219 wants to merge 15 commits intowp-cli:mainfrom
Conversation
…s_absolute() works (wp-cli#6115)
- Converted PathTest to extend PHPUnit\Framework\TestCase with proper data providers and assertions. - Removed use of globals and inline test scripts. - Ensured coding standards via PHPCS/PHPCBF (Runner.php and PathTest.php are clean). Note: CI failures are unrelated to this change. Existing tests (e.g. ArgValidationTest.php) still reference WP_CLI\Tests\TestCase, which no longer exists upstream.
- Added extra datasets to cover edge cases: * Empty string (not absolute) * Root directory / (absolute on UNIX) * UNC path \\Server\Share (currently not treated as absolute) - Ensured coding standards compliance via PHPCS/PHPCBF. - Test file now passes with 8 datasets and 8 assertions.
wp-cli#6115) - Normalize paths starting with drive-letter + forward slash (e.g. C:/path) into drive-letter + backslash (C:\path). - Add PHPUnit test (PathTest) to verify absolute path recognition on Windows and Unix. - Update composer.json autoload-dev to register WP_CLI\Tests\ namespace so TestCase loads correctly in PHPUnit.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
I disagree this is something If a limit is set, that is intentional. If overriding fixes it, then the site owner/server admin should decide if that is something that should be change. These limits are often there to say "If this is triggered, something is wrong and should be changed". |
|
FWIW, WP-CLI already sets the memory limit when it loads WordPress: Lines 1384 to 1386 in 04f9932 So this change here doesn't really make sense. Apart from that, there are way too many flaws in this (AI-generated) PR anyway. |
|
Hey @swissspidy, totally understand your concern. |
|
Apologies in that case for my assumption! I hope my comment wasn't too harsh. There were a few observations that led me to this conclusion:
We're happy to help with your next contribution, just reach out in the #cli Slack channel at any time :) |
Summary
This PR addresses issue #6123, where WP-CLI inherits the default WordPress memory limit (256M) instead of using an unlimited value.
When large operations are performed (e.g., plugin updates, database imports, or backup commands), this limitation can trigger fatal “Allowed memory size exhausted” errors.
Changes introduced
Testing
Related discussions
#6123
Similar request context: WP_CLI should not inherit restrictive web memory limits.
✅ Ready for review.
This change is backward-compatible and only affects CLI context.