New error logger#658
Open
alexander-b-clean wants to merge 16 commits into
Open
Conversation
AntonV1211
requested changes
May 18, 2026
AntonV1211
requested changes
May 18, 2026
Glomberg
reviewed
May 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new developer logging mechanism for the plugin and replaces direct error_log() usage with a WordPress-state-backed ring buffer logger, while also enforcing error_log bans via Psalm.
Changes:
- Added
SpbcDevLogger(ring-buffer persisted in State underdev_log) and a baseDevLogger. - Replaced multiple
error_log()call sites withSpbcDevLogger::write()and updated enqueue error reporting to route through an overridableerrorWrite(). - Added Psalm forbidden-function rule for
error_log()and introduced PHPUnit coverage for the new logger.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/lib/CleantalkSP/SpbctWP/TestSpbcDevLogger.php | Adds PHPUnit coverage for SpbcDevLogger storage, formatting, and ring-buffer behavior. |
| security-malware-firewall.php | Adds SpbcDevLogger import, includes dev_log in State options, and replaces one error_log() call. |
| psalm.xml | Forbids error_log() usage in Psalm. |
| lib/CleantalkSP/SpbctWP/State.php | Adds dev_log defaults, dev_logger property, and includes dev_log in resetState() options. |
| lib/CleantalkSP/SpbctWP/SpbcRateLimit/SpbcRateLimiter.php | Routes rate-limiter debug logging through SpbcDevLogger. |
| lib/CleantalkSP/SpbctWP/SpbcEnqueue.php | Implements errorWrite() to route enqueue errors into SpbcDevLogger. |
| lib/CleantalkSP/SpbctWP/SpbcDevLogger.php | Introduces the new State-persisted ring-buffer developer logger. |
| lib/CleantalkSP/SpbctWP/Scanner/Surface.php | Replaces error_log() with SpbcDevLogger when encountering symlinks during scanning. |
| lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php | Replaces several error_log() calls with SpbcDevLogger and adds structured context logging for one case. |
| lib/CleantalkSP/SpbctWP/Scanner/FrontendScan.php | Stops logging malformed HTML parse errors (commented rationale). |
| lib/CleantalkSP/SpbctWP/FSWatcher/Logger.php | Replaces error_log() file-append logging with file_put_contents() and uses SpbcDevLogger for failures. |
| lib/CleantalkSP/SpbctWP/Firewall/FW.php | Replaces a firewall exception error_log() with SpbcDevLogger. |
| lib/CleantalkSP/SpbctWP/Deactivator.php | Routes deactivation error logging through SpbcDevLogger. |
| lib/CleantalkSP/SpbctWP/AdjustToEnvironmentModule/AdjustToEnv/AdjustToEnvW3TotalCache.php | Replaces error_log() with structured SpbcDevLogger calls. |
| lib/CleantalkSP/Common/Helpers/IP.php | Routes one IPv6-support warning through DevLogger::write() instead of error_log(). |
| lib/CleantalkSP/Common/Helpers/DevLogger.php | Adds a base logger wrapper currently implemented via error_log(). |
| lib/CleantalkSP/Common/Enqueue/Enqueue.php | Makes Enqueue abstract, replaces direct error_log() with errorWrite(), and renames internal error accumulator method. |
| inc/spbc-admin.php | Replaces admin logging error_log() calls with SpbcDevLogger. |
| composer.json | Adds a new dependency entry (cleantalk/spbct-helpers) alongside existing analyser packages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
alexandergull
approved these changes
May 19, 2026
| * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html | ||
| * @see https://github.com/CleanTalk/security-malware-firewall | ||
| */ | ||
| class DevLogger |
Member
There was a problem hiding this comment.
Why do we need a new class? We have already implemented almost the same
AntonV1211
approved these changes
May 20, 2026
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.
https://app.doboard.com/1/task/35717