Skip to content

Fix TestCase::expectErrorLog() with open_basedir php.ini - #6227

Closed
mvorisek wants to merge 3 commits into
sebastianbergmann:12.3from
mvorisek:fix_6197
Closed

Fix TestCase::expectErrorLog() with open_basedir php.ini#6227
mvorisek wants to merge 3 commits into
sebastianbergmann:12.3from
mvorisek:fix_6197

Conversation

@mvorisek

@mvorisek mvorisek commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

fix #6197

rebased version of #6208 (because of #6208 (comment))

}
}
} elseif ($this->expectErrorLog) {
$this->markTestIncomplete('Could not create writable error_log file.');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unresolved feedback from the original PR - #6208 (comment)

The question is what to throw here, incomplete, risky, ...?

@mvorisek mvorisek Jul 20, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sebastianbergmann kindly ping as discussed in the previous PR.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Treating the test as incomplete (or risky) is too weak, IMO. This should be an error.

@sebastianbergmann
sebastianbergmann deleted the branch sebastianbergmann:12.3 July 31, 2025 12:00
@sebastianbergmann

sebastianbergmann commented Jul 31, 2025

Copy link
Copy Markdown
Owner

I forgot about branch retargeting (again). However, I was able to regarget this pull request to 12.3. Sorry for the noise.

@sebastianbergmann
sebastianbergmann changed the base branch from 12.2 to 12.3 July 31, 2025 12:50
@sebastianbergmann

Copy link
Copy Markdown
Owner

The more I think about #6197 and the changes proposed here to address it, the more I seem to lean towards "won't fix".

PHPUnit is a development tool that should only be used in a development environment. I cannot think of a situation where it makes sense to configure open_basedir in a development environment so that error_log() does not work. But maybe I am missing something?

As it stands, I am not convinced that the added complexity of providing a more specific error message for this edge case is worthwhile.

@mvorisek

Copy link
Copy Markdown
Contributor Author

We run our whole development (and production) suite with open_basedir configured.

The reason is we can protect our enviroment (project's unrelated files) better. This way we also assert no code accesses locations outside the projects.

This single issue prevents us to upgrade to PHPUnit 12.

I hope this can be fixed. I hope this PR is more like a bugfix, the tmp location can be readonly, not accessible at all, etc., so the file creation should be handled in any case.

To finish this PR, I have reopened #6227 (comment) discussion. Please guide me how to emit an error you want or feel free to commit into this PR directly.

@sebastianbergmann

Copy link
Copy Markdown
Owner

This pull request has conflicts that must be resolved.

@mvorisek

Copy link
Copy Markdown
Contributor Author

PR rebased

@sebastianbergmann

Copy link
Copy Markdown
Owner

Thank you for your patience.

I have cherry-picked your changes to 12.3, refactored the code, and changed it to treat the situation where a file for error_log() capturing cannot be created as an error.

@mvorisek

Copy link
Copy Markdown
Contributor Author

Thank you!

For documentation purposes, the change is in cc6414a.

@mvorisek
mvorisek deleted the fix_6197 branch August 12, 2025 09:24
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants