Skip to content

Upgrade to Monolog v3 compatibility - #36

Merged
markheydon merged 17 commits into
mainfrom
upgrade-to-monolog3
Aug 14, 2026
Merged

markheydon merged 17 commits into
mainfrom
upgrade-to-monolog3

Conversation

@markheydon

Copy link
Copy Markdown
Owner

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

- 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.
@markheydon markheydon linked an issue Jul 13, 2026 that may be closed by this pull request
@markheydon markheydon self-assigned this Jul 13, 2026
@markheydon markheydon added the story A user-facing feature, improvement, or technical task. label Jul 13, 2026
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Composer package changes
Prod Packages (1 packages)
Prod Packages Operation Base Target
monolog/monolog Upgraded 2.11.0 3.10.0
Dev Packages (15 packages)
Dev Packages Operation Base Target
composer/pcre Upgraded 3.3.2 3.4.0
nikic/php-parser Upgraded v5.7.0 v5.8.0
phpunit/php-code-coverage Upgraded 12.5.6 12.5.7
phpunit/phpunit Upgraded 12.5.25 12.5.31
sebastian/comparator Upgraded 7.1.7 7.1.8
sebastian/environment Upgraded 8.1.0 8.1.2
sebastian/global-state Upgraded 8.0.2 8.0.3
squizlabs/php_codesniffer Upgraded 4.0.1 4.0.4
symfony/config Upgraded v7.4.10 v7.4.14
symfony/dependency-injection Upgraded v7.4.10 v7.4.14
symfony/deprecation-contracts Upgraded v3.7.0 v3.7.1
symfony/finder Upgraded v7.4.8 v7.4.14
symfony/polyfill-mbstring Upgraded v1.37.0 v1.38.2
symfony/service-contracts Upgraded v3.7.0 v3.7.1
symfony/var-exporter Upgraded v7.4.9 v7.4.14

@markheydon markheydon moved this from Backlog to In Review in Mark's Workboard Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 WPCLIHandler to accept Monolog 3 LogRecord objects and use Level enum semantics throughout.
  • Raise Composer constraints to PHP ^8.1 and 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('');
        }

Comment thread src/Monolog/Handler/WPCLIHandler.php Outdated
Comment thread UPGRADE.md
Comment thread docs-internal/README.md Outdated
markheydon and others added 5 commits July 29, 2026 19:55
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>
@markheydon
markheydon merged commit b38b1f0 into main Aug 14, 2026
19 checks passed
@markheydon
markheydon deleted the upgrade-to-monolog3 branch August 14, 2026 14:57
@github-project-automation github-project-automation Bot moved this from In Review to Done in Mark's Workboard Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

story A user-facing feature, improvement, or technical task.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Compatibility for Monolog v3

2 participants