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

[DoctrineBundle] The proxy file ... does not exist issue #1535

Closed
mschneid opened this issue Jul 5, 2011 · 12 comments
Closed

[DoctrineBundle] The proxy file ... does not exist issue #1535

mschneid opened this issue Jul 5, 2011 · 12 comments

Comments

@mschneid
Copy link

mschneid commented Jul 5, 2011

With the new RC 4 I receive several "The proxy file "%s" does not exist. If you still ..." exceptions. If I remove the boot function in Symfony\Bundle\DoctrineBundle\DoctrineBundle everything works fine. It seems to me that the new doctrine autoloader mechanism isn't compatible with this code.

@mschneid mschneid closed this as completed Jul 7, 2011
@akloboucnik
Copy link

Mya I ask why this is closed? I'm still having this issue, even with current HEAD...

@mschneid mschneid reopened this Jul 11, 2011
@stof
Copy link
Member

stof commented Jul 11, 2011

Could you provide a way to reproduce your issue ? I don't have it.

@mschneid
Copy link
Author

The problem only occurs if you use an entity with associations as security provider (Entity implements the AdvancedUserInterface). If you clear the cache while your login session is still running, symfony will not be able to create the proxy files at the next request.

By now I found two solutions for this problem:

  • Create an empty file (e.g. with touch ../cache/AcmeIssueBundleEntityCategoryProxy.php)
    or
  • Remove the boot function in Symfony\Bundle\DoctrineBundle\DoctrineBundle

What do you think, is the boot function in the DoctrineBundle class still necessary (with the new doctrine autoloader mechanism)? For me everything works perfectly without these lines.

@stof
Copy link
Member

stof commented Jul 11, 2011

if you remove the boot function, The proxy cannot be autoloaded when unserializing the token, which makes your application fail when you have a proxy object as user interface (or as a related entity if you serialize them too).

The new Doctrine autoloader mechanism is for annotations. It has nothing to do with proxies.
Doctrine does not register an autoloader for its proxies. It requires the cached file when the class does not exist yet. So Doctrine itself does not need to autoload the proxies. But this is needed when you unserialize a proxy as you don't call Doctrine before.

If you have a serialized proxy object in your token and don't have the proxy class, there is no way to make it work properly. Your case may work when removing the method if the proxy is not your User class but a related entity as the main object has its class. But the related object is created as a __PHP_Incomplete_Class__ which means your object is in a broken state and the methods using the related object will fail.
To clear your cache, use the CLI command which warms up the proxies. This way you don't have this issue about non-existant proxies.

@akloboucnik
Copy link

Ok, thanks for the help - updating Doctrine stuff to 2.1.0 and adding new annotation loading mechanism to autoload.php made it work, so thanks for the explanation and sorry for bothering.

@Adamamont
Copy link

Hmm, I still have this bug with using cache:clear.

@pogotc
Copy link

pogotc commented Aug 30, 2011

I'm still having this issue using cache:clear as well, that's with the final 2.0 release.

@mschneid
Copy link
Author

Clear your PHP Session by hand:

rm /var/lib/php5/*

@Adamamont
Copy link

I suppose, that it isn't good solution for production.

@Adamamont
Copy link

This issue only for developer environment. In production everything is OK.

@fabpot
Copy link
Member

fabpot commented Sep 30, 2011

fixed in #1968

@juanmaia
Copy link

I see that it is closed, but im still getting this bug.
Basically im not using mysql at all, just mongodb and it seems to be looking for the wrong files as the message i get is:

The proxy file "/home/caderno/Symfony/app/cache/dev/doctrine/orm/Proxies/CadernoCadernaoBundleDocumentRoleProxy.php" does not exist. If you still have objects serialized in the session, you need to clear the session manually.

I think its looking just in the orm path..
I have also generated the proxies with doctrine:mongodb:generate:proxies

For the authentication i created my own service and my config.yml goes like

providers:
        default:
            id: caderno_security_provider

Any ideas?

fabpot added a commit to symfony/form that referenced this issue Nov 25, 2013
Commits
-------

0e00e3f [DoctrineBundle] CS
0c4b793 [DoctrineBundle] Fixed performances issues on "On-demand" proxy file generation
e866a67 [DoctrineBundle] Tries to auto-generate the missing proxy files on the autoloader

Discussion
----------

[DoctrineBundle] Tries to auto-generate the missing proxy files on the autoloaded

See:
symfony/symfony#1965
symfony/symfony#1535

This fix is not really clean and there's maybe a factorizing work to do on it, but this work and avoid me spending my day deleting session cookies each time I clear cache.

---------------------------------------------------------------------------

by stloyd at 2011/08/23 10:37:28 -0700

You should follow Symfony2 CS (http://symfony.com/doc/current/contributing/code/standards.html).

---------------------------------------------------------------------------

by ruudk at 2011/09/26 02:50:13 -0700

+1

---------------------------------------------------------------------------

by fabpot at 2011/09/27 07:01:51 -0700

It looks like a bug fix, so this PR should be closed and a new one based on the 2.0 branch should be open. @beberlei: are you fine with this patch?

---------------------------------------------------------------------------

by beberlei at 2011/09/29 04:24:22 -0700

What is this for? I dont understand the bug and the solution here screams cache slam.

---------------------------------------------------------------------------

by beberlei at 2011/09/29 04:34:02 -0700

Ok i get the problem but the solution is still a monsterous hack. Can we find a real solution to the problem? There has to be one.

---------------------------------------------------------------------------

by Gregwar at 2011/09/29 04:34:25 -0700

@beberlei, when an user is authenticated for instance, there can be proxies serialized in session.

Si if you clear the cache in dev environment you'll get an error because the matching proxy classes won't exist and you'll be forced to clear your cookies and reauth, which can be annoying

---------------------------------------------------------------------------

by Gregwar at 2011/09/29 04:38:45 -0700

@beberlei, yes, I agree that we should do something more elegant, but the problem is that when PHP "meet" the proxy class we can't really know what was the "original" class it is supposed to extend

And as @schmittjoh said, this will only be executed very rarely

---------------------------------------------------------------------------

by beberlei at 2011/09/29 05:18:35 -0700

You agree you want something more suitable and still want this to be merged?

To ease the immediate pain wr could allow this however only in debug mode. A real solution here is maybe to move the proxy files out of the env folders. Rhey dont depend ont the env after all.

---------------------------------------------------------------------------

by stloyd at 2011/09/29 05:21:33 -0700

Proxy is not depending on env, but generation of proxy is... So this solution will be hard IMO, or even unacceptable...

---------------------------------------------------------------------------

by Gregwar at 2011/09/29 05:25:39 -0700

@beberlei what I meant is that I agree that's dirty but I don't think of anything better to solve this...

---------------------------------------------------------------------------

by fabpot at 2011/09/29 06:23:03 -0700

Even if the current patch is not the best solution, we should probably apply it to fix the problem and think about a better solution afterwards. Does it sound good for everybody?
gencer pushed a commit to gencer/DoctrineModule that referenced this issue Apr 11, 2014
Commits
-------

0e00e3f [DoctrineBundle] CS
0c4b793 [DoctrineBundle] Fixed performances issues on "On-demand" proxy file generation
e866a67 [DoctrineBundle] Tries to auto-generate the missing proxy files on the autoloader

Discussion
----------

[DoctrineBundle] Tries to auto-generate the missing proxy files on the autoloaded

See:
symfony/symfony#1965
symfony/symfony#1535

This fix is not really clean and there's maybe a factorizing work to do on it, but this work and avoid me spending my day deleting session cookies each time I clear cache.

---------------------------------------------------------------------------

by stloyd at 2011/08/23 10:37:28 -0700

You should follow Symfony2 CS (http://symfony.com/doc/current/contributing/code/standards.html).

---------------------------------------------------------------------------

by ruudk at 2011/09/26 02:50:13 -0700

+1

---------------------------------------------------------------------------

by fabpot at 2011/09/27 07:01:51 -0700

It looks like a bug fix, so this PR should be closed and a new one based on the 2.0 branch should be open. @beberlei: are you fine with this patch?

---------------------------------------------------------------------------

by beberlei at 2011/09/29 04:24:22 -0700

What is this for? I dont understand the bug and the solution here screams cache slam.

---------------------------------------------------------------------------

by beberlei at 2011/09/29 04:34:02 -0700

Ok i get the problem but the solution is still a monsterous hack. Can we find a real solution to the problem? There has to be one.

---------------------------------------------------------------------------

by Gregwar at 2011/09/29 04:34:25 -0700

@beberlei, when an user is authenticated for instance, there can be proxies serialized in session.

Si if you clear the cache in dev environment you'll get an error because the matching proxy classes won't exist and you'll be forced to clear your cookies and reauth, which can be annoying

---------------------------------------------------------------------------

by Gregwar at 2011/09/29 04:38:45 -0700

@beberlei, yes, I agree that we should do something more elegant, but the problem is that when PHP "meet" the proxy class we can't really know what was the "original" class it is supposed to extend

And as @schmittjoh said, this will only be executed very rarely

---------------------------------------------------------------------------

by beberlei at 2011/09/29 05:18:35 -0700

You agree you want something more suitable and still want this to be merged?

To ease the immediate pain wr could allow this however only in debug mode. A real solution here is maybe to move the proxy files out of the env folders. Rhey dont depend ont the env after all.

---------------------------------------------------------------------------

by stloyd at 2011/09/29 05:21:33 -0700

Proxy is not depending on env, but generation of proxy is... So this solution will be hard IMO, or even unacceptable...

---------------------------------------------------------------------------

by Gregwar at 2011/09/29 05:25:39 -0700

@beberlei what I meant is that I agree that's dirty but I don't think of anything better to solve this...

---------------------------------------------------------------------------

by fabpot at 2011/09/29 06:23:03 -0700

Even if the current patch is not the best solution, we should probably apply it to fix the problem and think about a better solution afterwards. Does it sound good for everybody?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants