我正在使用Laravel 5.1制作电子商务网络应用程序。在检查应用程序的管理面板以编辑特定产品时,我得到了一个例外:
FatalErrorException in Container.php line 1057:
Maximum function nesting level of '100' reached, aborting!
我已在我的应用程序中实现了Repository Pattern,它仍处于开发阶段。
这是堆栈跟踪:
in Container.php line 1057
at FatalErrorException->__construct() in HandleExceptions.php line 133
at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 118
at HandleExceptions->handleShutdown() in HandleExceptions.php line 0
at Container->make() in Application.php line 674
at Application->make() in Container.php line 1157
at Container->offsetGet() in DatabaseManager.php line 251
at DatabaseManager->getDefaultConnection() in DatabaseManager.php line 85
at DatabaseManager->parseConnectionName() in DatabaseManager.php line 61
at DatabaseManager->connection() in Model.php line 3209
at Model::resolveConnection() in Model.php line 3175
at Model->getConnection() in Model.php line 2946
at Model->getDateFormat() in Model.php line 2879
at Model->fromDateTime() in Model.php line 2838
at Model->setAttribute() in Model.php line 422
at Model->fill() in Model.php line 445
at Model->Illuminate\Database\Eloquent\{closure}() in Model.php line 2295
at Model::unguarded() in Model.php line 446
at Model->forceFill() in Pivot.php line 54
at Pivot->__construct() in Model.php line 1937
at Model->newPivot() in BelongsToMany.php line 1124
at BelongsToMany->newPivot() in BelongsToMany.php line 1137
at BelongsToMany->newExistingPivot() in BelongsToMany.php line 257
at BelongsToMany->hydratePivotRelation() in BelongsToMany.php line 178
at BelongsToMany->get() in BelongsToMany.php line 99
at BelongsToMany->getResults() in Model.php line 2699
at Model->getRelationshipFromMethod() in Model.php line 2665
at Model->getRelationValue() in Model.php line 2607
at Model->getAttribute() in Model.php line 3325
at Model->__get() in Model.php line 46
at Product->getCategoryIdAttribute() in Model.php line 2722
at Model->mutateAttribute() in Model.php line 2624
at Model->getAttributeValue() in Model.php line 3394
at Model->__isset() in FormBuilder.php line 3348
at Model->offsetExists() in FormBuilder.php line 404
at data_get() in FormBuilder.php line 1048
at FormBuilder->getModelValueAttribute() in FormBuilder.php line 1035
at FormBuilder->getValueAttribute() in FormBuilder.php line 487
at FormBuilder->select() in Facade.php line 219
at Facade::__callStatic() in 400c2ba760310cd2966e41d1b593cf85 line 24
at FormFacade::select() in 400c2ba760310cd2966e41d1b593cf85 line 24
in PhpEngine.php line 42
at PhpEngine->evaluatePath() in CompilerEngine.php line 58
at CompilerEngine->get() in View.php line 138
at View->getContents() in View.php line 107
at View->renderContents() in View.php line 81
at View->render() in e6c9a42799c231accc0d1cb4aa2d16d0 line 47
in PhpEngine.php line 42
at PhpEngine->evaluatePath() in CompilerEngine.php line 58
at CompilerEngine->get() in View.php line 138
at View->getContents() in View.php line 107
at View->renderContents() in View.php line 81
at View->render() in Response.php line 51
at Response->setContent() in Response.php line 202
at Response->__construct() in Router.php line 1225
at Router->prepareResponse() in ControllerDispatcher.php line 113
at ControllerDispatcher->Illuminate\Routing\{closure}() in Pipeline.php line 139
at call_user_func() in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}() in AdminLoggedIn.php line 20
at AdminLoggedIn->handle() in Pipeline.php line 124
at call_user_func_array() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 103
at call_user_func() in Pipeline.php line 103
at Pipeline->then() in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack() in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch() in Route.php line 201
at Route->runWithCustomDispatcher() in Route.php line 134
at Route->run() in Router.php line 704
at Router->Illuminate\Routing\{closure}() in Pipeline.php line 139
at call_user_func() in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 103
at call_user_func() in Pipeline.php line 103
at Pipeline->then() in Router.php line 706
at Router->runRouteWithinStack() in Router.php line 671
at Router->dispatchToRoute() in Router.php line 631
at Router->dispatch() in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}() in Pipeline.php line 139
at call_user_func() in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}() in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle() in Pipeline.php line 124
at call_user_func_array() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in ShareErrorsFromSession.php line 54
at ShareErrorsFromSession->handle() in Pipeline.php line 124
at call_user_func_array() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in StartSession.php line 62
at StartSession->handle() in Pipeline.php line 124
at call_user_func_array() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle() in Pipeline.php line 124
at call_user_func_array() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in EncryptCookies.php line 59
at EncryptCookies->handle() in Pipeline.php line 124
at call_user_func_array() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle() in Pipeline.php line 124
at call_user_func_array() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 103
at call_user_func() in Pipeline.php line 103
at Pipeline->then() in Kernel.php line 122
at Kernel->sendRequestThroughRouter() in Kernel.php line 87
at Kernel->handle() in index.php line 54
in server.php line 21
at {main}() in server.php line 0
问题是,当我尝试从管理面板编辑产品时,我得到了上述异常,但我可以从管理面板插入新产品。
我知道我可以将xdebug.max_nesting_level = 100
增加到xdebug.max_nesting_level = 500
,但这不是我要找的。我正在为客户开发应用程序,他们可能正在拥有自己的服务器。因此,我不能将此作为我的解决方案。
通过做一些研究,我被带到this question,但接受的答案是使用wamp
作为他的服务器而我正在使用LAMP。
我犯了什么/错误在哪里?
非常感谢任何帮助。感谢。
更新1:
经过对堆栈跟踪的一些研究后,我发现它与我正在使用的形式有关:
form.blade.php
<div class="row">
<div class="col-md-4 col-sm-6">
<div class="form-group">
{!! Form::label('code', 'Code:') !!}
{!! Form::text('code', null, ['class' => 'form-control input-sm']) !!}
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class="form-group">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control input-sm']) !!}
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class="form-group">
{!! Form::label('category_id', 'Category:') !!}
<!-- Here's the error: $categoryList -->
{!! Form::select('category_id[]', $categoryList, null, ['class' => 'form-control input-sm categoryList', 'multiple']) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-6">
<div class="form-group">
{!! Form::label('sort', 'Sort:') !!}
{!! Form::text('sort', null, ['class' => 'form-control input-sm']) !!}
</div>
</div>
<div class="col-md-12 col-sm-12">
<div class="form-group">
{!! Form::label('special_note', 'Special Note:') !!}
{!! Form::textarea('special_note', null, ['class' => 'form-control input-sm ckeditor', 'id' => 'prdSpecialNote'] ) !!}
</div>
</div>
</div>
<div class="form-group">
{!! Form::submit($submitButtonText, ['class' => 'btn btn-primary btn-block', 'id' => $submitButtonId]) !!}
</div>
Product.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Product extends Model
{
use SoftDeletes;
/**
* The dates that will be used as Carbon instance
*
* @var array
*/
protected $dates = ['deleted_at'];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'code', 'name', 'description', 'special_note', 'sort', 'display'
];
/**
* The Many-To-Many relationship between the category and
* the product.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function categories()
{
return $this->belongsToMany('App\Category')->withTimestamps();
}
/**
* Get the array of App\Category.
*
* @return array
*/
public function getCategoryIdAttribute()
{
// If I comment this line, the error disappears
// but the category_id field becomes blank
// And if I leave it as it is
// It throws the error exception
return $this->categories->lists('id');
}
}
P.S。我正在使用安装了LAMP的Ubuntu 14.04 LTS x64bit架构。我也在使用Form Model Binding。
答案 0 :(得分:-1)
我很抱歉缺乏精确性,但看起来有一个递归函数更深入,可能是因为数据库查询使用了蹩脚的雄辩ORM。
我可以建议你尝试定位哪个函数调用,并尝试自己重写SQL语句。