Skip to content

[ClassLoader] Fix storing not-found classes in APC cache #18312

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

Merged
merged 1 commit into from
Mar 28, 2016

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 2.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

@xabbuh
Copy link
Member

xabbuh commented Mar 26, 2016

Did this cause issues somewhere? The docs state that the return value will also be false on failures.

@nicolas-grekas
Copy link
Member Author

Its false on failure, but also false when false is the cached value... $success is the way to check for cache hit or miss.

@xabbuh
Copy link
Member

xabbuh commented Mar 26, 2016

👍 ah of course

Status: Reviewed

@@ -118,11 +118,13 @@ public function loadClass($class)
*
* @param string $class A class name to resolve to file
*
* @return string|null
* @return string|false
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not seem correct. The other class loaders have string|null. As they are decorated by ApcClassLoader something is wrong. If they do not return false at all, then this whole change seems irrelevant.

@Tobion
Copy link
Contributor

Tobion commented Mar 26, 2016

Status: Needs Work

@nicolas-grekas
Copy link
Member Author

@Tobion fixed
Status: needs review

$file = apcu_fetch($this->prefix.$class, $success);

if (!$success) {
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null);
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the point of the null condition?

Copy link
Member Author

Choose a reason for hiding this comment

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

Composer's ClassLoader returns false here.

Copy link
Contributor

Choose a reason for hiding this comment

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

then WinCache and Xcache class loaders should do the same normalization

@Tobion
Copy link
Contributor

Tobion commented Mar 27, 2016

ApcUniversalClassLoader needs the same fix.

@nicolas-grekas
Copy link
Member Author

@Tobion PR updated

@Tobion
Copy link
Contributor

Tobion commented Mar 28, 2016

Thank you @nicolas-grekas.

@Tobion Tobion merged commit 106ed06 into symfony:2.3 Mar 28, 2016
Tobion added a commit that referenced this pull request Mar 28, 2016
…nicolas-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[ClassLoader] Fix storing not-found classes in APC cache

| Q             | A
| ------------- | ---
| Branch?       | 2.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

106ed06 [ClassLoader] Fix storing not-found classes in APC cache
@nicolas-grekas nicolas-grekas deleted the apc-classload branch March 30, 2016 06:44
@fabpot fabpot mentioned this pull request Mar 30, 2016
This was referenced Apr 29, 2016
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.

4 participants