cakephp(2.7.8)
PHP 5.6
MySQL 5.6
試験の問題一覧ページを、ページネーションで作りました。
ページ番号のクリックでページ移動します。
以下のような画面です。
画面上では正常に動作してるのですが、遷移した後にエラーログが出力されます。
正確には、
・ページ遷移時に毎回出力されるエラー
と、
・どのタイミングか分からないのですが、まれに出力されるエラー
の2つ発見しました。
毎回の方を「エラー1」、
タイミングが分からない方を「エラー2」とします。
コントローラー
php
1 2public function ques_list() { 3 4 if ($this->request->is('get')) { 5 6 7 //試験を取得 8 $exam_id = $this->request->query['exam']; 9 10 //使うモデルをロードする 11 $this->loadModel("Question"); 12 $this->loadModel("Certificate"); 13 14 15 $this->paginate = $this->Question->getOptions(); 16 17 //検索条件 18 $conditions = array('Question.exam_id' => $exam_id); 19 20 $question = $this->paginate('Question',$conditions); 21 $this->set('question',$question); 22 23 24 //資格+試験名 25 $exam = new Exam(); 26 $e = $exam->findById($exam_id); 27 28 29 $c = $this->Certificate->findById($e['Exam']['certificate_id']); 30 31 32 //ここでまれにエラー2が発生 33 $hoge = '【' . $c['Certificate']['name'] . '試験】' . $e['Exam']['name']; 34 $this->set('exam_name',$hoge); 35 36 37 //タイトルをセットしてるのに、毎回エラー1が発生 38 $this->set('title', $hoge . '試験の問題一覧'); 39 40 } 41 42 43 } 44 45
ビュー
html
1 <title> 2 <?php echo $title; ?> 3 </title>
debug.log
エラー1
log
12019-06-12 16:32:08 Notice: Notice (8): Undefined variable: title in [/home/users/2/boo.jp-dancer/web/kako/app/View/Layouts/default.ctp, line 11] 2Trace: 3ErrorHandler::handleError() - CORE/Cake/Error/ErrorHandler.php, line 230 4include - APP/View/Layouts/default.ctp, line 11 5View::_evaluate() - CORE/Cake/View/View.php, line 971 6View::_render() - CORE/Cake/View/View.php, line 933 7View::renderLayout() - CORE/Cake/View/View.php, line 546 8View::render() - CORE/Cake/View/View.php, line 481 9Controller::render() - CORE/Cake/Controller/Controller.php, line 963 10ExceptionRenderer::_outputMessage() - CORE/Cake/Error/ExceptionRenderer.php, line 292 11ExceptionRenderer::error400() - CORE/Cake/Error/ExceptionRenderer.php, line 236 12ExceptionRenderer::render() - CORE/Cake/Error/ExceptionRenderer.php, line 190 13ErrorHandler::handleException() - CORE/Cake/Error/ErrorHandler.php, line 127 14[main] - [internal], line ?? 15
エラー2
log
12019-05-25 13:34:59 Notice: Notice (8): Undefined index: Certificate in [/home/users/2/boo.jp-dancer/web/kako/app/Controller/ChecksController.php, line 103] 2Trace: 3ErrorHandler::handleError() - CORE/Cake/Error/ErrorHandler.php, line 230 4ChecksController::ques_list() - APP/Controller/ChecksController.php, line 103 5ReflectionMethod::invokeArgs() - [internal], line ?? 6Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 491 7Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 193 8Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 167 9[main] - APP/webroot/index.php, line 111 10
エラー1に関して、
titleはセットされている(ソースの表示→<title>がセットされているのを確認)のに、何故このようなエラーが出力されるのか見当も尽きません。
エラー2に関して
何らかのタイミング?原因で、「Certificate 」への参照が失敗しているのでしょうか?
ただ、こちらも画面では正常に動作しており、こちらも見当も尽きません。
何かヒントだけでも助かります。
分かる方教えていただけないでしょうか?
あなたの回答
tips
プレビュー