Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AnnotationFileLoader breaks on OSX Mounted Drives in Symfony 3.2.0 #21497

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

Closed
kphamilton opened this issue Feb 1, 2017 · 3 comments
Closed

AnnotationFileLoader breaks on OSX Mounted Drives in Symfony 3.2.0 #21497

kphamilton opened this issue Feb 1, 2017 · 3 comments

Comments

@kphamilton
Copy link

Q A
Bug report? yes
Feature request?
BC Break report? yes
RFC?
Symfony version 3.2.0

I develop in my local environment on OSX using a mounted network drive that is my Linux VM.

Some of you might know that OSX handles files and metadata from mounted drives in an interesting way. It creates an ".AppleDouble" directory, and then creates files in that directory that match the names of the parent directory (ie, Controller/BlogController.php and it creates Controller/.AppleDouble/BlogController.php that contains the metadata).

These files store encoded data about the original files. Because of that, they do not contain a php start tag (<?php)

I updated to Symfony 3.2.0 this morning and started receiving this exception:

The file "/path/Controller/.AppleDouble/BlogController.php" does not contain PHP code. Did you forgot to add the "<?php" start tag at the beginning of the file?

Everything works in 3.1.* and upon further examination, the change causing this was in PR #18869

That change occurred to assist in people who had copied and pasted code from a tutorial that did not have a start tag. Instead of it silently failing, it now throws an exception in the findClass() method of the AnnotationFileLoader to give a clearer reason why it failed.

The situation is that now it is attempting to load the ".php" files in my .AppleDouble directories, assuming they are actual PHP files, and it is not able to find a start tag, so an exception is thrown. In the past, it would simply not load those files, and my application would work.

I would rather not have to create a custom loader to get around this. Any thoughts or suggestions on what I can do? Thanks!

@linaori
Copy link
Contributor

linaori commented Feb 3, 2017

Besides of OSX modifying this (which sounds really wonky if you ask me), for this particular (OS Level) case, an exception could be made to exclude that directory. The problem is, if there's 1 exception to the rule, there are more.

@javiereguiluz
Copy link
Member

I wasn't aware of this .AppleDouble thing, but there are more Symfony developers affected in other ways. For example:

The autoloader expected class "Thing\CoreBundle\Command.AppleDouble\EnsureIndexesCommand" to be defined in file "/var/www/mysite.com/Symfony/app/../src/Thing/CoreBundle/Command/.AppleDouble/EnsureIndexesCommand.php". The file was found but the class was not in it, the class name or namespace probably has a typo.


I'd say we should take care of this and exclude the .AppleDouble directory entirely and everywhere (although I don't know exactly how).

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Feb 23, 2017 via email

fabpot added a commit that referenced this issue Mar 2, 2017
…om annotations (jakzal)

This PR was merged into the 2.7 branch.

Discussion
----------

[Routing] Ignore hidden directories when loading routes from annotations

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21497
| License       | MIT
| Doc PR        | -

The problem surfaced after implementing #18869. Therefore it doesn't exist on 2.7, but I'd still merge it there to avoid conflicts when merging between branches. Without this fix, the oldest branch the added test will fail is 3.2.

Commits
-------

ce9df02 [Routing] Ignore hidden directories when loading routes from annotations
@fabpot fabpot closed this as completed Mar 2, 2017
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

6 participants