3

I'm running a Laravel 4.0 application on Amazon Elastic Beanstalk using the Amazon Linux 64-bit with PHP 5.4.21 standard AMI.

Whenever a git aws.push completes or when Amazon's default daily cron jobs run (which causes Apache to restart), my application suddenly has exceptions in Eloquent based-model create calls until I restart Apache, sometimes 1-2 times. From then on, the server will run normally until the next Apache restart (via daily job or git push, etc.)

[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 for brevity. MyApp\Store\Order extends Eloquent.

I'm really at a loss as to how to diagnose and ultimately fix this issue and am seeking advice.

Update: I've removed the calling functions that were requested below as they don't seem relevant. They pass all tests, and have been successfully processing thousands of orders. This happens with at least one other Eloquent-based model (i.e. MyApp\User) when calling create() on it too until Apache is restarted 1-2 times.

2
  • Can you post process method? Isn't it the one throwing exception? Did you look into who are the callers for the method? Commented Dec 23, 2013 at 6:08
  • Exception occurs inside Laravel's Model class, in the getAttribute() function, specifically a call to array_key_exists($key, $this->attributes). $this->attributes, somehow doesn't exist, even though its initialized as an empty array in the class. Commented Dec 23, 2013 at 9:17

3 Answers 3

2

I've upgraded to the recently announced PHP 5.5 environment, and this problem has gone away. I believe it had something to do with the APC cache (which isn't in 5.5) but I can't say that with certainty.

Sign up to request clarification or add additional context in comments.

Comments

0

Increasing the amount of RAM I was giving my VM from 2GB to 4GB appears to have resolved this issue for me. Turns out eager loading is RAM-hungry.

Comments

0

Increasing php.ini memory usage from 512M to 1024M did the job for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.