访问未声明的静态属性:Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver :: [英] Access to undeclared static property: Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::

查看:101
本文介绍了访问未声明的静态属性:Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver ::的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在面临这个关键问题,所有我的文档都有一个@ ODM\UniqueIndex,@ ODM\InheritanceType,@ ODM\DiscriminatorField等定义的字段。基本上,如果该类没有任何@ ODM\Document注释,那么在尝试使用DocumentManager检索文档时,我会收到以下错误:



对于某些原因是试图使用像$D7 1等奇怪字符来访问静态属性。发生了什么?有人可以帮我解决这个问题,因为我们在这个项目中遇到了路障。正在使用ODM的最新主分支。



注意:只有当APC被启用时,才会抛出此异常。如果我禁用APC并重新启动apache,它可以正常工作。此外,当APC被使能时,它在第一次加载时工作,但是对于每个连续的请求都失败。 (猜测这是因为APC操作码缓存仅在第一个请求后填写)



错误



 致命错误:访问未声明的静态属性:Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver :: $ Sin / home / dayson / projects / www / textme / ninja / library / Doctrine / ODM / MongoDB / Mapping / Driver / AnnotationDriver.php第146行

调用堆栈
#时间内存函数位置
... ..
6 0.0037 1319032 Doctrine\ODM\MongoDB\DocumentManager-> find()../Test.php:34
7 0.0038 1322736 Doctrine\ODM\MongoDB\DocumentManager - > getRepository()../DocumentManager.php:574
8 0.0038 1322736 Doctrine\ODM\MongoDB\DocumentManager-> getClassMetadata()../DocumentManager.php:474
9 0.0038 1322736 Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory-> getMetadataFor()../DocumentManager.php:27 3
10 0.0038 1322736 Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory-> loadMetadata()../ClassMetadataFactory.php:180
11 0.0050 1495432 Doctrine\ODM\MongoDB\\ \\Mapping\Driver\AnnotationDriver-> loadMetadataForClass()../ClassMetadataFactory.php:243



代码



  $ dm-> find('Document\User','4e283aabc2749a4b7d0001dd')



文件代码



  ;?php 
命名空间文档;
使用Doctrine\ODM\MongoDB\Mapping\Annotations作为ODM;

/ **
* @ ODM\Document
* @ ODM\UniqueIndex(keys = {mobile=asc})
*
类用户扩展\Document\AbstractDocument
{
/ **
* @var string
* @ ODM\Id
* /
protected $ id;

/ **
* @var string
* @ ODM\String
* /
protected $ mobile;

}


解决方案

与APC 3.1.3p1的错误。我升级到3.1.9版,现在已经解决了。



希望这样可以为将来可能遇到的其他人节省一些时间。不要使用debian / ubuntu存储库中的APC软件包。请使用PECL。


I'm facing this critical issue on all my Documents which have either an @ODM\UniqueIndex, @ODM\InheritanceType, @ODM\DiscriminatorField, etc field defined for. Basically, if there's anything more than an @ODM\Document annotation for the class, I get the error below while trying to retrieve a document using the DocumentManager:

For some reason it's trying to access a static property with weird characters like $D7�1, etc. What's happening? Could someone please help me resolve this as we've hit a roadblock in our project due to this. The latest master branch of the ODM is being used.

Note: This exception only happens to be thrown when APC is enabled. If I disable APC and restart apache, it works fine. Also when APC is enabled, it works on the first load, but fails for every consecutive request. (Guess this is happening because the APC opcode cache is populated only after the first request)

Error

Fatal error: Access to undeclared static property: Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::$�S in /home/dayson/projects/www/textme/ninja/library/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php on line 146

Call Stack
#   Time    Memory  Function    Location
.....
6   0.0037  1319032 Doctrine\ODM\MongoDB\DocumentManager->find( )   ../Test.php:34
7   0.0038  1322736 Doctrine\ODM\MongoDB\DocumentManager->getRepository( )  ../DocumentManager.php:574
8   0.0038  1322736 Doctrine\ODM\MongoDB\DocumentManager->getClassMetadata( )   ../DocumentManager.php:474
9   0.0038  1322736 Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory->getMetadataFor( )    ../DocumentManager.php:273
10  0.0038  1322736 Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory->loadMetadata( )  ../ClassMetadataFactory.php:180
11  0.0050  1495432 Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver->loadMetadataForClass( )   ../ClassMetadataFactory.php:243

Code

$dm->find('Document\User', '4e283aabc2749a4b7d0001dd')

Document Code

<?php
namespace Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
 * @ODM\Document
 * @ODM\UniqueIndex(keys={"mobile"="asc"})
 */
class User extends \Document\AbstractDocument
{
    /**
     * @var string
     * @ODM\Id
     */
    protected $id;

    /**
     * @var string
     * @ODM\String
     */
    protected $mobile;

}

解决方案

It's a bug with APC 3.1.3p1. I upgraded to version 3.1.9 and it's now resolved.

Hope this saves some time for other people who may encounter it in the future. Do not use the APC packages from the debian/ubuntu repositories. Use the PECL one instead.

这篇关于访问未声明的静态属性:Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver ::的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆