Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Debug] DebugClassLoader breaks with classes defined in eval()'d code on Mac/Darwin #30362

Closed
skalpa opened this issue Feb 24, 2019 · 0 comments

Comments

@skalpa
Copy link
Contributor

skalpa commented Feb 24, 2019

Symfony version(s) affected: 3.4

Description
When loading a class defined in eval()'d code DebugClassLoader::darwinRealpath() is unable to determine the real path of the file and a notice is triggered by the return $real .= $dirFiles[$kFile]; statement.

Additional context
The KernelTestCase PHPUnit 8 compatibility fix applied in #30124 defines KernelShutdownOnTearDownTrait in an eval() block and breaks the container compilation on mac.

[ErrorException]
Notice: Undefined index: kernelshutdownonteardowntrait.php(19) : eval()'d code 
Exception trace:
 () at /www/relendex/trading-api/vendor/symfony/debug/DebugClassLoader.php:450
 spl_autoload_call() at /www/relendex/trading-api/vendor/symfony/framework-bundle/Test/KernelTestCase.php:26

(The stack trace is from 4.2@dev, but the PR was merged to 3.4).

nicolas-grekas added a commit that referenced this issue Feb 24, 2019
…arDownTrait (skalpa)

This PR was merged into the 4.2 branch.

Discussion
----------

[FrameworkBundle] Removed eval() from KernelShutdownOnTearDownTrait

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Apart from triggering the #30362 bug, the `eval()` block from #30124 also broke my workflow: static code analyzers don't like this, and the trait even crashes PHPStan.

It may also bring up other compatibility issues to other people (ie: I know companies that completely disable `eval()` on their servers).

As it was only required to keep the trait compatible with PHP 5.x, it is unnecessary on 4.x that requires PHP 7.1+, and this PR removes it on the 4.2 branch.

Commits
-------

324b70a Removed eval() from KernelShutdownOnTearDownTrait
nicolas-grekas added a commit that referenced this issue Feb 24, 2019
…e on Darwin (skalpa)

This PR was squashed before being merged into the 3.4 branch (closes #30363).

Discussion
----------

Fixed the DebugClassLoader compatibility with eval()'d code on Darwin

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30362
| License       | MIT

When a class is defined in an `eval()` block, the reported file name is `file_name.php(123) : eval()'d code`, which prevents `DebugClassLoader::darwinRealpath()` from locating/normalizing the file name, and triggers a notice.

Commits
-------

6c2aa24 Fixed the DebugClassLoader compatibility with eval()'d code on Darwin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants