kayue / KayueWordpressBundle

A Symfony 2 bundle for providing WordPress repositories and authenticating users (login).
101 stars 43 forks source link

When doctrine:generate:entities - Error on TablePrefixSubscriber.php : getClassAnnotations() must be an instance of ReflectionClass #35

Closed hisem closed 9 years ago

hisem commented 10 years ago

When I run the doctrine:generate:entities command on my projet, I get this error:

PHP Catchable fatal error:  Argument 1 passed to Doctrine\Common\Annotations\AnnotationReader::getClassAnnotations() must be an instance of ReflectionClass, null given, called in .../vendor/kayue/kayue-wordpress-bundle/Kayue/WordpressBundle/Subscriber/TablePrefixSubscriber.php on line 31 and defined in .../vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php on line 153

I found a way to get around it here: https://github.com/orocrm/platform/issues/5

by adding this to Subscriber\TablePrefixSubscriber.php:

use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService;
public function loadClassMetadata(LoadClassMetadataEventArgs $args)
    {
        $classMetadata = $args->getClassMetadata();
        $rrs = new RuntimeReflectionService();
        $classMetadata->wakeupReflection($rrs);
[...]

though I honestly do not understand what's going on...

Does anyone else get this issue? Is it project-related? Can this work-around be used in any case and thus be added to this bundle?

Thanks.

kayue commented 10 years ago

@hisem Maybe related to this issue: #29

Maybe try to change it to an older version v1.1.0?

hisem commented 10 years ago

Hi @kayue,

Ok i tried switching back to v1.1.0 as I was on dev-master, but I straight away get this error on every page:

ORMException: Unknown Entity namespace alias 'KayueWordpressBundle'.

Any ideas? EDIT : I'm using this in production code, do you recon switching back to 1.1.0 will cause other issues for me?

Oh and does this mean issue #29 's feature should be fixed?

Many thanks,

hisem commented 10 years ago

Ah ok I got it, since I'm using a different entity manager than default there are some features that will be missing for me in v1.1.0 like 4d97c88eb428a69b88b0d0e254846cd831eb19b6

So I guess i'll switch back to dev-master and use the work-around I found for now... Since I'm not sure if the work-around will have an impact or not on others I won't propose it as a pull request, but you have everything you need in my code extract to use it if it's useful.

kayue commented 10 years ago

I see. Just FYI you can fix bundle to any commit you want, you don't have to use master branch in this case.

hisem commented 10 years ago

Oh right yeah, good idea, thanks for the tip!

wujku commented 8 years ago

I switch to last commit 451b5a19fdcadce6747125fe11a4c308a14cb528 and have that same issue when I run doctrine:generate:form. I use other connection for bundle.