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

Cache Warmup Breaks Namespaced Kernel #9525

Merged
merged 1 commit into from
Nov 23, 2013
Merged

Conversation

rdohms
Copy link
Contributor

@rdohms rdohms commented Nov 18, 2013

Q A
Bug fix? [yes]
New feature? [no]
BC breaks? [no]
Deprecations? [no]
Tests pass? have not tried yet
License MIT
Fixed tickets further fixes #1431

My kernel has been moved and namespaced to Cfs\Bundle\MultiSiteBundle\Kernel\CfsKernel. This worked fine until a change was made to how the kernel temp stuff is handled in the warmup phase.

When the app generates its own cache (i.e you run cache without warmup and access the site) everything is generated ok and the .meta files generate the proper reference to the FQN of the Kernel.

However if the warmup is used, it uses Cfs\Bundle\MultiSiteBundle\Kernel\CfsKerne_ as the temporary Kernel, and when it does "fix references to the Kernel in .meta files" it generates 2 errors.

  1. It does not use a string safe tempKernel name, so it never finds the reference to the kernel
  2. If you fix that, then it replaces the FQN of the tempKernel with CfsKernel, the non-namespaced name of the proper Kernel (it also leaves the character count wrong in the serialization C:43:<class> where 43 is the char count for the FQN above)

The two changes above fix this, by escaping the string and replacing it with a FQN Kernel Class name.

What are your thoughts on this? If this sounds reasonable i'll do further enhancements and check tests.

My kernel has been moved and namespaced to `Cfs\Bundle\MultiSiteBundle\Kernel\CfsKernel`. This worked fine until a change was made to how the kernel temp stuff is handled in the warmup phase.

When the app generates its own cache (i.e you run cache without warmup and access the site) everything is generated ok and the .meta files generate the proper reference to the FQN of the Kernel.

However if the warmup is used, it uses `Cfs\Bundle\MultiSiteBundle\Kernel\CfsKerne_` as the temporary Kernel, and when it does "fix references to the Kernel in .meta files" it generates 2 errors.

1. It does not use a string safe tempKernel name, so it never finds the reference to the kernel
2. If you fix that, then it replaces the FQN of the tempKernel with `CfsKernel`, the non-namespaced name of the proper Kernel (it also leaves the character count wrong in the serialization `C:43:<class>` where 43 is the char count for the FQN above)

The two changes above fix this, by escaping the string and replacing it with a FQN Kernel Class name.

What are your thoughts on this?
@@ -120,10 +120,14 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
$warmer->warmUp($warmupDir);

// fix references to the Kernel in .meta files

$safeTempKernel = str_replace('\\', '\\\\', get_class($tempKernel));
$realKernelFQN = get_class($realKernel);
Copy link
Member

Choose a reason for hiding this comment

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

AFAIU, this is the same value as $realKernelClass created above and which was used before. I must be missed something here but I don't see the difference.

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 i thought so to, but lines 108-110 actually strip the namespace from it, so it replaces /Namespaced/Kernel with Kernel

fabpot added a commit that referenced this pull request Nov 23, 2013
This PR was merged into the master branch.

Discussion
----------

Cache Warmup Breaks Namespaced Kernel

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | have not tried yet
| License       | MIT
| Fixed tickets | further fixes #1431

My kernel has been moved and namespaced to `Cfs\Bundle\MultiSiteBundle\Kernel\CfsKernel`. This worked fine until a change was made to how the kernel temp stuff is handled in the warmup phase.

When the app generates its own cache (i.e you run cache without warmup and access the site) everything is generated ok and the .meta files generate the proper reference to the FQN of the Kernel.

However if the warmup is used, it uses `Cfs\Bundle\MultiSiteBundle\Kernel\CfsKerne_` as the temporary Kernel, and when it does "fix references to the Kernel in .meta files" it generates 2 errors.

1. It does not use a string safe tempKernel name, so it never finds the reference to the kernel
2. If you fix that, then it replaces the FQN of the tempKernel with `CfsKernel`, the non-namespaced name of the proper Kernel (it also leaves the character count wrong in the serialization `C:43:<class>` where 43 is the char count for the FQN above)

The two changes above fix this, by escaping the string and replacing it with a FQN Kernel Class name.

What are your thoughts on this? If this sounds reasonable i'll do further enhancements and check tests.

Commits
-------

9e7788e Cache Warmup Breaks Namespaced Kernel
@fabpot fabpot merged commit 9e7788e into symfony:master Nov 23, 2013
@rdohms
Copy link
Contributor Author

rdohms commented Nov 25, 2013

@fabpot, how do i proceed to get this into the 2.3 branch? just open a PR on that branch?

rdohms added a commit to rdohms/symfony that referenced this pull request Nov 25, 2013
fabpot added a commit that referenced this pull request Nov 26, 2013
…dohms)

This PR was merged into the 2.3 branch.

Discussion
----------

Adjusting CacheClear Warmup method to namespaced kernels

Backported the patch in #9525 to the 2.3 branch.

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | have not tried yet
| License       | MIT
| Fixed tickets | further fixes #1431

My kernel has been moved and namespaced to `Cfs\Bundle\MultiSiteBundle\Kernel\CfsKernel`. This worked fine until a change was made to how the kernel temp stuff is handled in the warmup phase.

When the app generates its own cache (i.e you run cache without warmup and access the site) everything is generated ok and the .meta files generate the proper reference to the FQN of the Kernel.

However if the warmup is used, it uses `Cfs\Bundle\MultiSiteBundle\Kernel\CfsKerne_` as the temporary Kernel, and when it does "fix references to the Kernel in .meta files" it generates 2 errors.

1. It does not use a string safe tempKernel name, so it never finds the reference to the kernel
2. If you fix that, then it replaces the FQN of the tempKernel with `CfsKernel`, the non-namespaced name of the proper Kernel (it also leaves the character count wrong in the serialization `C:43:<class>` where 43 is the char count for the FQN above)

The two changes above fix this, by escaping the string and replacing it with a FQN Kernel Class name.

What are your thoughts on this? If this sounds reasonable i'll do further enhancements and check tests.

Commits
-------

00d79d5 Adjusting CacheClear Warmup method to namespaced kernels
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.

Cache warmup problem
2 participants