Upgrade to Monolog v3 compatibility - #36
Merged
Merged
Conversation
- Updated WPCLIHandler to replace Logger level constants with Level enum cases. - Changed method signatures to accept LogRecord objects instead of arrays. - Refactored level normalization and validation methods to accommodate new Level enum. - Updated tests to reflect changes in WPCLIHandler and ensure compatibility with Monolog v3. - Adjusted runtime smoke tests and WordPress fixture to utilize the new Level enum.
Composer package changesProd Packages (1 packages)
Dev Packages (15 packages)
|
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request moves mhcg/monolog-wp-cli onto the Monolog 3 release line by raising the runtime floor to PHP 8.1+, updating the handler implementation to Monolog 3 APIs (Level + LogRecord), and aligning tests/CI/docs with the new compatibility baseline.
Changes:
- Update
WPCLIHandlerto accept Monolog 3LogRecordobjects and useLevelenum semantics throughout. - Raise Composer constraints to PHP
^8.1and Monolog^3.0, and refresh unit/runtime/WordPress smoke CI coverage accordingly. - Add and update upgrade + compatibility documentation for the v2 → v3 transition.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
UPGRADE.md |
Adds a public upgrade guide for Monolog 2 → 3 migration. |
src/Monolog/Handler/WPCLIHandler.php |
Refactors core handler for Monolog 3 (Level, LogRecord) and updates level mapping logic. |
tests/Monolog/Handler/WPCLIHandlerTest.php |
Updates unit tests to construct and assert against Monolog 3 LogRecord objects and Level values. |
tests/runtime-smoke.php |
Updates runtime smoke test setup to use Level::Debug. |
tests/wordpress/fixtures/monolog-wp-cli-smoke/monolog-wp-cli-smoke.php |
Updates WordPress smoke fixture to use Level::Debug. |
composer.json |
Raises runtime requirements to PHP ^8.1 and Monolog ^3.0. |
composer.lock |
Updates locked dependencies for the new Monolog/PHP baseline. |
README.md |
Updates stated requirements and adds CI workflow badge. |
docs/how-to/test-under-wordpress.md |
Documents the current WordPress/PHP smoke tuple set and how to run it locally. |
docs/explanation/compatibility-and-release-line-policy.md |
Updates the compatibility narrative to reflect the Monolog 3 release line. |
docs-internal/php-version-strategy.md |
Refreshes the internal PHP strategy snapshot for the new baseline. |
docs-internal/wordpress-support-policy.md |
Updates internal WordPress tuple policy snapshot and wording. |
docs-internal/upgrade-from-monolog-v2-to-v3.md |
Adds internal phased migration/verification notes for the Monolog 3 transition. |
docs-internal/README.md |
Adds an index entry for the internal Monolog v2 → v3 upgrade doc. |
.github/workflows/php.yml |
Removes PHP 7.x/8.0 jobs and updates WordPress smoke tuple matrix. |
.github/workflows/ci.yml |
Adds a coverage workflow with a minimum coverage threshold gate. |
Comments suppressed due to low confidence (1)
src/Monolog/Handler/WPCLIHandler.php:53
- The constructor throws a RuntimeException with an empty message when not running under WP-CLI, which makes failures hard to diagnose (especially in tests/CI). Use a clear message explaining the WP-CLI precondition.
$isInCLI = (defined('WP_CLI') && WP_CLI);
if (!$isInCLI) {
throw new \RuntimeException('');
}
The integration fixture now requires mhcg/monolog-wp-cli via a path repository and loads its own vendor autoload, matching how real plugins consume the package and closing the gap before closing #20. Co-authored-by: Cursor <cursoragent@cursor.com>
Improve WPCLIHandler map resolution and validation, expand exit-path tests, build the smoke fixture outside the package tree for Composer path installs, use --entrypoint wp for reliable WP-CLI output, bump PHPCS for CVE-2026-67434, and remove the duplicate WordPress integration workflow. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the package to be compatible with Monolog v3, including refactoring the WPCLIHandler to utilize the new Level enum and adjusting method signatures to accept LogRecord objects. CI configurations and documentation have been updated to reflect these changes.
Fixes #20