Skip to content

[2.3][Enhancement][FrameworkBundle] Move the warmup logic to the CacheWarmerAggregate #6223

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
wants to merge 7 commits into from

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Dec 7, 2012

This is mainly moving logic from the cache clear command to its own class so that it could be called more easily (ie from the WDT).

Feedback ?

rename($realCacheDir, $oldCacheDir);
$oldCacheDir = $cacheDir.'__old__';
rename($cacheDir, $oldCacheDir);
$this->getContainer()->get('filesystem')->remove($oldCacheDir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed as it is already done after the condition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you should remove the other one instead.

@vicb
Copy link
Contributor Author

vicb commented Dec 11, 2012

@fabpot sorry for this messy PR, but I wanted to have some feedback before polishing the code.
Would it be accepted ?

@fabpot
Copy link
Member

fabpot commented Dec 11, 2012

The approach looks good to me. The only thing I'm not sure about is whether the logic belongs to the cache warmer aggregate or to another (new) class (I tend to think that the latter would be better).

@vicb
Copy link
Contributor Author

vicb commented Dec 11, 2012

You are probably right. It would also avoid a BC break (warmers position in the constructor). I'll update after I have time to think about it.

@vicb
Copy link
Contributor Author

vicb commented Dec 11, 2012

@fabpot what about CacheWarmerDumper ?

}

// fix meta references to the Kernel
foreach ($finder->files()->name('*.meta')->in($warmupDir) as $file) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot:

  • is reusing the finder intended (or a bug) here ?
  • is handling serialized class only (vs string, ie paths) intended ?

Thanks, too tired to figure out by myslef tonight !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • all refs seem to be handled - 3rd party bundles ?
  • I am mainly talking about the cache folder in string (ie a:9:{i:0;C:46:"Symfony\Component\Config\Resource\FileResource":60:{s:52:"/var/www/sf2.2/app/cache/dev_new/as)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reuse of the finder is indeed a bug.

@vicb
Copy link
Contributor Author

vicb commented Dec 17, 2012

@schmittjoh would you please have a look why this fails when the cache folder is empty ?

Fatal error: Cannot redeclare class EnhancedProxy_72114c0f8683bcc2a66ceccb136abe5a78f8577e\__CG__\Acme\DemoBundle\Controller\SecuredController in /var/www/sf2.2/app/cache/dev__new__/jms_diextra/proxies/Acme-DemoBundle-Controller-SecuredController.php on line 28

@schmittjoh
Copy link
Contributor

It's not something that I can debug soon, but as a pointer it is likely
something that needs to be updated in the ControllerWarmer.

On Mon, Dec 17, 2012 at 11:31 AM, Victor Berchet
notifications@github.comwrote:

@schmittjoh https://github.com/schmittjoh would you please have a look
why this fails when the cache folder is empty ?

Fatal error: Cannot redeclare class EnhancedProxy_72114c0f8683bcc2a66ceccb136abe5a78f8577e__CG__\Acme\DemoBundle\Controller\SecuredController in /var/www/sf2.2/app/cache/dev__new__/jms_diextra/proxies/Acme-DemoBundle-Controller-SecuredController.php on line 28


Reply to this email directly or view it on GitHubhttps://github.com//pull/6223#issuecomment-11436754.

@vicb
Copy link
Contributor Author

vicb commented Dec 17, 2012

Thanks, think I got it, need to test... magic values !!!

On 12/17/2012 04:43 PM, Johannes wrote:

It's not something that I can debug soon, but as a pointer it is likely
something that needs to be updated in the ControllerWarmer.

On Mon, Dec 17, 2012 at 11:31 AM, Victor Berchet
notifications@github.comwrote:

@schmittjoh https://github.com/schmittjoh would you please have a
look
why this fails when the cache folder is empty ?

Fatal error: Cannot redeclare class
EnhancedProxy_72114c0f8683bcc2a66ceccb136abe5a78f8577e__CG__\Acme\DemoBundle\Controller\SecuredController
in
/var/www/sf2.2/app/cache/dev__new__/jms_diextra/proxies/Acme-DemoBundle-Controller-SecuredController.php
on line 28


Reply to this email directly or view it on
GitHubhttps://github.com//pull/6223#issuecomment-11436754.


Reply to this email directly or view it on GitHub
#6223 (comment).

@vicb
Copy link
Contributor Author

vicb commented Dec 17, 2012

BC PR pending.

On 12/17/2012 04:43 PM, Johannes wrote:

It's not something that I can debug soon, but as a pointer it is likely
something that needs to be updated in the ControllerWarmer.

On Mon, Dec 17, 2012 at 11:31 AM, Victor Berchet
notifications@github.comwrote:

@schmittjoh https://github.com/schmittjoh would you please have a
look
why this fails when the cache folder is empty ?

Fatal error: Cannot redeclare class
EnhancedProxy_72114c0f8683bcc2a66ceccb136abe5a78f8577e__CG__\Acme\DemoBundle\Controller\SecuredController
in
/var/www/sf2.2/app/cache/dev__new__/jms_diextra/proxies/Acme-DemoBundle-Controller-SecuredController.php
on line 28


Reply to this email directly or view it on
GitHubhttps://github.com//pull/6223#issuecomment-11436754.


Reply to this email directly or view it on GitHub
#6223 (comment).

@vicb
Copy link
Contributor Author

vicb commented Dec 18, 2012

@fabpot this is ready to be merged @schmittjoh has merged the PR to the DIXtra

@fabpot
Copy link
Member

fabpot commented Dec 18, 2012

So, you fixed Johannes bundle but what if other bundles out there did the same? What about reverting to using the current suffixes?

@vicb
Copy link
Contributor Author

vicb commented Dec 18, 2012

So, you fixed Johannes bundle

I prefer to think that I have fixed the usage of magic values.

May be the PR should not be squashed at it contains different things.

@fabpot
Copy link
Member

fabpot commented Mar 20, 2013

This PR should be updated with the recent changes made to the cache:clear command.

@vicb
Copy link
Contributor Author

vicb commented Mar 28, 2013

It would probably have been smarter to merge this PR before #7360 but it's too late and we have introduced yet a new bug (schmittjoh/JMSDiExtraBundle#96).

@jfsimon you will find the root cause of the bug you have introduced by looking at the comment of this PR (I did introduce the same bug at the start of the PR before making a fix on @schmittjoh repo).

Anyway I don't have a lot of time to work on this now and the work should happen after @jfsimon has fixed his PR. @jfsimon could you please take care of syncing this PR once you're done - ping me if you need help.

(This bug shows one more reason why magic values are evil for the ones who where not already convinced)

/cc @swis @craue

@jfsimon
Copy link
Contributor

jfsimon commented Mar 28, 2013

@vicb I wished I find you on Jabber... wouldn't it be more simple to rebase your PR on master?

@jfsimon
Copy link
Contributor

jfsimon commented Mar 28, 2013

@vicb PS: I have enough time to do it for you.

@vicb
Copy link
Contributor Author

vicb commented Mar 28, 2013

here I am... soon

@natebundy
Copy link

Hey guys, this is blocking us pretty hard in our current project where we're trying to use @secure to secure a REST API in Symfony2. Is there a way for us to help get this done? I'm willing to help any way I can including getting final code together for a pull request. Thanks!

@vicb
Copy link
Contributor Author

vicb commented Apr 2, 2013

I won't have time to look into this before the end of this week.

This is a bit tricky as the root cause of the issue has not been really identified (according to @jfsimon himself). I am talking about the fix done in #7360, not the "new" issue.

Then we have two options:

@fabpot what do you think ?

The current issue is not related to this PR and discussions should better switch to #7505 from now.

@vicb vicb closed this Jan 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants