我一直在研究一個小MVC項目,以協助我的自我學習,並且遇到了讓我完全困惑的問題。我在這個MVC-ish系統中創建了一個博客部分,並從ACL中提取了用戶權限,沒有任何問題。 我移動到創建一個部件區段,一旦我添加任何的權限檢查我從Chrome中出現以下錯誤:收到 無法因爲服務器發送任何數據,加載網頁兩個(幾乎)相同的代碼段產生單獨的結果
無數據。 以下是一些建議: 稍後重新加載此網頁。 錯誤324(net :: ERR_EMPTY_RESPONSE):服務器關閉連接而不發送任何數據。
我認爲這很奇怪,所以我再次檢查我的錯誤日誌,沒有顯示出來。所以我決定將工作博客代碼複製並粘貼到成員文件中,重新加載並得到相同的錯誤,現在兩個文件之間的唯一區別是文件名和類名。 以下是博客的代碼:
<?php
class blog extends frontController {
public $model;
public $user;
public function __construct()
{
parent::__construct();
$this->model = $this->autoload_model();
$this->user = $this->load_user();
$this->user->getUserRoles();
}
public function index()
{
//Will only list the latest post ;)
if(!$this->user->hasPermission('blog_access'))
{
$array = $this->model->list_posts();
if(empty($array))
{
$this->variables(array(
'site_title' => 'View Blog Posts',
'post_title' => 'Sorry but there are no posts to display'
));
} else {
$this->variables(array(
'site_title' => 'View Blog Posts',
'list' => $array[0],
'post_title' => $array[0]['entry_title'],
'link' => str_replace(' ', '_',$array[0]['entry_title']),
));
}
} else {
$this->variables(array(
'site_title' => 'Error :: Design Develop Realize',
'body' => 'Sorry, but you do not have permission to access this',
));
}
$this->parse('blog/list', $this->toParse);
}
這是成員文件:
<?php
class member extends frontController {
public $model;
public $user;
public function __construct()
{
parent::__construct();
$this->model = $this->autoload_model();
$this->user = $this->load_user();
$this->user->getUserRoles();
}
public function index()
{
//Will only list the latest post ;)
if(!$this->user->hasPermission('blog_access'))
{
//$array = $this->model->list_posts();
if(empty($array))
{
$this->variables(array(
'site_title' => 'Design Develop Realize :: View Blog Posts',
'post_title' => 'Sorry but there are no posts to display'
));
} else {
$this->variables(array(
'site_title' => 'Design Develop Realize :: View Blog Posts',
'list' => $array[0],
'post_title' => $array[0]['entry_title'],
'link' => str_replace(' ', '_',$array[0]['entry_title']),
));
}
} else {
$this->variables(array(
'site_title' => 'Error :: Design Develop Realize',
'body' => 'Sorry, but you do not have permission to access this',
));
}
$this->parse('blog/list', $this->toParse);
}
在成員類,如果我註釋掉$this->user = $this->load_user();
然後錯誤消失! 僅供參考下面是一個函數:
protected function load_user()
{
if(!$this->loader->loaded['acl'])
{
$this->loader->loadCore('acl');
}
return $this->loader->loaded['acl'];
}
任何幫助或建議將作爲我難倒不勝感激!
PS是的我有錯誤報告設置涵蓋一切,沒有它不記錄任何東西!
編輯:因爲所有的文件都要經過的index.php我已經把錯誤報告有:
<?php
error_reporting(E_ALL);
ini_set('date.timezone', "Europe/London");
require_once('system/library/loader.php');
$loader = new loader();
$loader->loadCore(array('frontController', 'routing'));
編輯2: loadCore()低於
public function loadCore($toLoad, $params = false)
{
//important task first, check if it is more then 1 or not
if(is_array($toLoad))
{
//more then one so lets go to the task!
foreach($toLoad as $file)
{
if(file_exists('system/library/' . $file . '.php'))
{
require_once('system/library/' . $file . '.php');
if($params)
{
$this->loaded[$file] = new $file($params);
} else {
$this->loaded[$file] = new $file;
}
} else {
trigger_error("Core File $file does not exist");
}
}
} else {
//Phew, less work, it is only one!
if(file_exists('system/library/' . $toLoad . '.php'))
{
require_once('system/library/' . $toLoad . '.php');
if($params)
{
echo(__LINE__); exit;
$this->loaded[$toLoad] = new $toLoad($params);
} else {
$this->loaded[$toLoad] = new $toLoad;
}
}
}
}
更新:我修改了loadCore,所以如果是被調用的acl,它會使用try ... catch()並且沒有幫助,因爲它不會顯示錯誤ju st相同的鉻和IE頁
更新2:我已經說過我的主機,似乎每當這個錯誤發生,apache記錄以下(不知道爲什麼我看不到它在我的日誌副本! )
[週三02月22日8時07分11秒2012] [錯誤] [客戶93.97.245.13]過早結束腳本頭 :index.php文件
你能說明你是如何設置錯誤報告的嗎?你在看哪些日誌?因爲像這樣的東西絕對應該留下痕跡的地方 – 2012-02-15 11:19:50
我已經更新了問題,顯示佩卡 – 2012-02-15 11:28:13
你能嘗試把的error_reporting行權違規調用的前面,以排除它被設置爲「安靜」一些呢?你能指定你在看哪些日誌嗎? – 2012-02-15 11:35:53