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

Regenerating hydrators do not refresh them #29

Open
mirfilip opened this issue Feb 5, 2015 · 6 comments
Open

Regenerating hydrators do not refresh them #29

mirfilip opened this issue Feb 5, 2015 · 6 comments
Labels

Comments

@mirfilip
Copy link

mirfilip commented Feb 5, 2015

First of all, I'm not sure whether this is a bug, an expected behaviour or a missing feature, so please go easy :)

I try to use pre-generating hydrators feature and hook it up with my deployment system. I've created generate.php script with a snippet doing basically what documentation says (and it works fine). I, then, intend to use it with pre-autoload-dump composer event script in order to achieve fresh hydrators for my objects every time I run composer install/update (regardless if it's development or production env).

The reason I want fresh hydrators every time is that the default values / attributes can easily change during development.

Because of a class existence check in HydratorFactory::getHydratorClass(), HydratorFactory will not attempt to create a proxy class when it already exists. I think pre-generation is intended for production usage only, when classes are not meant to get changed (thus hydrators don't need refreshing). Anyway, removing this class existence check makes it fit my scenario. How do you feel about forceRefresh kind of flag @Ocramius ?

Alternatively, do you have any ideas how to work it around ?

@mirfilip mirfilip closed this as completed Feb 6, 2015
@mirfilip mirfilip reopened this Feb 6, 2015
@Ocramius
Copy link
Owner

Ocramius commented Feb 6, 2015

@mirfilip good point. I think the simplest way would be to implement signing like Ocramius/ProxyManager#172

@Ocramius Ocramius added the bug label Feb 6, 2015
@Ocramius Ocramius added this to the 1.2.0 milestone Feb 6, 2015
@Ocramius
Copy link
Owner

Ocramius commented Feb 6, 2015

@mirfilip consider that I don't have time to fix this bug right now, so consider sending a PR after looking in the linked PR.

@mirfilip
Copy link
Author

mirfilip commented Feb 6, 2015

@Ocramius I'll try to have a go, sure.

@gonzaloserrano
Copy link

Hey guys, we just hit the same issue. Any further news about this?

@mirfilip
Copy link
Author

@gonzaloserrano, I'll be looking at this this week(end), stay in touch

@gonzaloserrano
Copy link

Hi again, i found the root cause of my issue and i think it's not related.

Somehow some (3) files from generated files stored in /tmp had root permissions, so then when the default generation strategy was executed the rename here https://github.com/Ocramius/CodeGenerationUtils/blob/master/src/CodeGenerationUtils/GeneratorStrategy/FileWriterGeneratorStrategy.php#L78 failed, which caused two problems:

  • /tmp had thousands of generated temporal files
  • the new files where not substituting the old ones because the rename() failed so they had the old structure

I have changed those file permissions and i think now it works as expected.

Thanks for your time.

@Ocramius Ocramius modified the milestone: 1.2.0 Jan 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants