Add possibility to cache annotations wih APC #405

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants

zim32 commented Jul 21, 2012

APC has a bug - after apc_fetch is made, arrays loose their cursors. That is why is_numeric(key(...)) is not working

@stof stof commented on the diff Jul 21, 2012

lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
@@ -60,8 +60,9 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
$classAnnotations = $this->reader->getClassAnnotations($class);
- if ($classAnnotations && is_numeric(key($classAnnotations))) {
- foreach ($classAnnotations as $annot) {
+ if ($classAnnotations) {
+ foreach($classAnnotations as $key=>&$annot) {
@stof

stof Jul 21, 2012

Member

Please fix the CS. A space is missing after foreach and around the =>. And I don't see why you need to get $annot by reference

@stof stof commented on the diff Jul 21, 2012

lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
@@ -60,8 +60,9 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
$classAnnotations = $this->reader->getClassAnnotations($class);
- if ($classAnnotations && is_numeric(key($classAnnotations))) {
- foreach ($classAnnotations as $annot) {
+ if ($classAnnotations) {
+ foreach($classAnnotations as $key=>&$annot) {
+ if(!is_numeric($key)) continue;
@stof

stof Jul 21, 2012

Member

missing space after if and missing curly braces

@guilhermeblanco

guilhermeblanco Jul 23, 2012

Owner

Also, missing space around !.

This pull request passes (merged f6d5ff9 into 93cef61).

Owner

beberlei commented Jul 29, 2012

Can you link this APC bug?

zim32 commented Jul 29, 2012

Can't find it. But you can try this code

$array = array('foo',2,3,4,5);
var_dump(current($array)); //foo
apc_store('foo',$array);
$array2 = apc_fetch('foo');
var_dump(current($array2)); //false

beberlei closed this Jul 29, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment