在Amazon ELB上使用Laravel 4:$attributes未定义属性

3
我正在使用Amazon Linux 64位和PHP 5.4.21标准AMI在Amazon Elastic Beanstalk上运行一个Laravel 4.0应用程序。
每当git aws.push完成或Amazon默认的每日cron作业运行(导致Apache重启),我的应用程序会突然出现Eloquent基于模型的创建调用异常,直到我重新启动Apache,有时需要多次。从那时起,服务器将正常运行,直到下一次Apache重启(通过每日作业或git push等方式)。
[2013-12-22 19:34:52] log.ERROR: Exception in orderProcessor->process: 
exception 'ErrorException' with message 'Undefined property: 
MyApp\Store\Order::$attributes' in /v/a/c/bootstrap/compiled.php:6266
Stack trace:
#0 /v/a/c/bootstrap/compiled.php(6266): Illuminate\Exception\Handler->handleError(8, 'Undefined prope...', '/v/a/c...', 6266, Array)
#1 /v/a/c/bootstrap/compiled.php(6461): Illuminate\Database\Eloquent\Model->getAttribute('attributes')
#2 /v/a/c/bootstrap/compiled.php(6379): Illuminate\Database\Eloquent\Model->__get('attributes')
#3 /v/a/c/bootstrap/compiled.php(5530): Illuminate\Database\Eloquent\Model->syncOriginal()
#4 /v/a/c/bootstrap/compiled.php(5589): Illuminate\Database\Eloquent\Model->__construct(Array)
#5 /v/a/c/app/MyApp/Store/Repositories/EloquentOrderRepository.php(62): Illuminate\Database\Eloquent\Model::create(Array)
#6 /v/a/c/app/MyApp/Store/OrderProcessor.php(65): MyApp\Store\Repositories\EloquentOrderRepository->create(Array)
#7 /v/a/c/app/controllers/StoreController.php(122): MyApp\Store\OrderProcessor->process(Object(MyApp\User), Object(MyApp\Store\Cart))
... controller and route calls ...

/v/a/c表示/var/app/current,为了简洁起见。MyApp\Store\Order继承自Eloquent。
我真的不知道如何诊断和最终解决这个问题,正在寻求建议。
更新:我已经删除了下面要求的调用函数,因为它们似乎不相关。它们通过了所有测试,并且已经成功处理了数千个订单。当在至少另一个基于Eloquent的模型(即MyApp\User)上调用create()时,直到Apache重新启动1-2次才会出现此问题。

你能发布process方法吗?它不是抛出异常的方法吗?你有没有查看调用该方法的调用者是谁? - kukido
在Laravel的Model类中,getAttribute()函数内发生了异常,具体是调用了array_key_exists($key, $this->attributes)。尽管在该类中将其初始化为空数组,但$this->attributes却不存在。 - LF.
3个回答

2

我已经升级到了最近宣布的PHP 5.5环境,这个问题已经消失了。我相信这与APC缓存有关(在5.5中不存在),但我不能确定。


0

将php.ini内存使用量从512M增加到1024M对我来说起了作用。


0

将虚拟机的RAM从2GB增加到4GB似乎已经解决了我的问题。原来急切加载需要大量的RAM。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接