Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add possibility to cache annotations wih APC #405

Closed
wants to merge 1 commit into from

5 participants

@zim32

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
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 added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stof stof commented on the diff
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 added a note

missing space after if and missing curly braces

@guilhermeblanco Owner

Also, missing space around !.

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

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

@beberlei
Owner

Can you link this APC bug?

@zim32

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 beberlei closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 21, 2012
  1. @zim32

    Fix for apc bug, when apc is lossing array cursor after apc_fetch. No…

    zim32 authored
    …w it is possible to cache annotation info
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
View
5 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 added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if(!is_numeric($key)) continue;
@stof
stof added a note

missing space after if and missing curly braces

@guilhermeblanco Owner

Also, missing space around !.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
$classAnnotations[get_class($annot)] = $annot;
}
}
Something went wrong with that request. Please try again.