Repository navigation
feat(php-unit): fail when core's error handler swallowed PHP errors - #101
Merged
Merged
Conversation
A test bootstrap that loads lib/base.php without PHPUNIT_RUN gets core's production OC\Log\ErrorHandler, and PHPUnit's own handler backs off. Every notice, warning and deprecation then went to owncloud.log, and the job stayed green. wopi's unit suite and notes' integration suite are built that way today. Record the size of owncloud.log before the PHPUnit steps. Afterwards, fail if any entry appended since then was logged with app "PHP". Only that handler writes such entries, so the check tests the failure itself, however the bootstrap is put together. Refs owncloud/core#41904 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Thomas Müller <323649642+oc-tmueller@users.noreply.github.com>
oc-tmueller
force-pushed
the
feat/php-unit-swallowed-php-errors
branch
from
October 15, 2026 13:48
1cd149d to
83bcf22
Compare
Contributor
Author
Contributor
Author
|
Proof that the check fires, and that it doesn't fire when it shouldn't.
|
oc-tmueller
force-pushed
the
feat/php-unit-swallowed-php-errors
branch
from
October 15, 2026 14:20
c7c058e to
83bcf22
Compare
Contributor
Author
phil-davis
approved these changes
Oct 16, 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.
A test bootstrap that loads
lib/base.phpwithout definingPHPUNIT_RUNgets core's productionOC\Log\ErrorHandler, and PHPUnit 9's own handler then backs off. Every notice, warning and deprecation goes toowncloud.log, and the job stays green. That is how firewall's suite hid the hoa deprecations for years. See owncloud/core#41904.What it does. The workflow records the size of
data/owncloud.logjust before "Run PHPUnit". After the PHPUnit and integration steps it fails if any appended entry has"app":"PHP". OnlyOC\Log\ErrorHandlerwrites that (verified by grepping core master), and inside PHPUnit that handler is active only when the bootstrap skippedPHPUNIT_RUN. So the check catches the failure itself, however the bootstrap is put together. Up to 20 entries are printed, followed by an::error::that says how to fix it.Why here and not in core. The alternative was detecting PHPUnit in
lib/kernel.php, viaPHPUNIT_COMPOSER_INSTALL. That relies on an undocumented PHPUnit internal and puts test-runner detection on the production boot path. It would also hide only the error handler, while those suites keep using the production config dir, memcache, locking and session crypto.PHPUNIT_RUNis already the mechanism, so this PR enforces it.Rollout. Every app calls
php-unit.yml@main, so the affected apps were fixed first. All three are merged:phpunit.integration.xml)owncloud/firewall#792 (replacing the
set_error_handler(null)workaround) is independent of this PR: firewall writes no"app":"PHP"entries with either bootstrap.The other 48 classic apps define
PHPUNIT_RUN, chain to core's bootstrap, never loadbase.php, or have no PHP tests. None of their unit or integration suites spawns a PHP subprocess, and none moves the log (logfile/log_type/debug). Locally, wopi's suite wrote 0 such entries before its fix, so turning the check on shouldn't make any current suite red.Proof that it fires: see the CI runs linked in this comment. A temporary commit planted a bootstrap-less
base.phpload plus anE_USER_WARNINGinside the test window, and the step went red in all 8 PHP Unit / Integration jobs. The commit was then dropped, and the head is back on the green tree.🤖 Generated with Claude Code