douyi2107 2013-03-07 18:08
浏览 45
已采纳

APC致命:缺少班级信息

According to this PHP bug report, the error message is caused by nesting a class in an if statement and having it declared statically as well.

I have a class declared in only one place, but I've protected it with an if:

if (!class_exists('myClass', false)) {
    class myClass{

(Trying to do something similar to the C++ pre-processor directives / conditional inclusions.)

This was to prevent failing from the possibility of multiple coders including it improperly (require instead of require_once). My only other alternative at this point is to comment out the if's and search the application for includes and just make them all "require_once's".

So, has anyone else ran into this error, and is there a way to get around besides changing all the requires to require_once? (This software is maintained by multiple coders, so I'd like to keep it from failing.)

  • This error only occurs on occasion (randomly) and when it does, I have to add / remove a space from the class file and re-save to fix the error.

On a side note, the main reason we installed APC was for file upload progress support for IE 9 and under. So if we can keep just those parts enabled we could disable whatever feature causes this. (Not sure if that's possible.)

Update: Resaving the file apparently doesn't have an effect. It looks like it has a sort of "timeout". When the error occurs, I have to simply wait a while for it to go away.

  • 写回答

1条回答 默认 最新

  • duanke9540 2013-03-07 19:05
    关注

    It seems that this may be caused by autoloading classes as well as including class dependencies in the classes themselves.

    Before we had upgraded to PHP 5.3, we didn't have the option of using PHP's autoloading functionality. We therefore had to include the class dependencies in the class file. For example:

    <?php
    require "parent_class.php";
    
    if (!class_exists('this_class')) {
        class this_class extends parent_class {
    

    When we upgraded to PHP 5.3, we implemented the class autoloading functionality. This is probably how the "static" and "dynamic" class declarations (according to the PHP Bug in the question) are occuring. - Statically being declared in the actual class file and dynamically being declared in the autoloader.

    I went through and removed all of the includes / requires for class dependencies. This has solved the problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码