3232use phpMyFAQ \Filter ;
3333use phpMyFAQ \Helper \LanguageHelper ;
3434use phpMyFAQ \Link ;
35+ use phpMyFAQ \Question ;
3536use phpMyFAQ \Session \Token ;
3637use phpMyFAQ \Translation ;
3738use phpMyFAQ \Twig \Extensions \FormatBytesTwigExtension ;
@@ -537,20 +538,22 @@ public function answer(Request $request): Response
537538 'admin-answer-question ' . $ questionId ,
538539 );
539540
540- $ question = $ this ->container ->get (id: 'phpmyfaq.question ' )->get ($ questionId );
541+ /** @var Question $question */
542+ $ question = $ this ->container ->get (id: 'phpmyfaq.question ' );
543+ $ questionData = $ question ->get ($ questionId );
541544
542545 $ faqData = [
543546 'id ' => 0 ,
544547 'lang ' => $ this ->configuration ->getLanguage ()->getLanguage (),
545- 'title ' => $ question ['question ' ],
548+ 'title ' => $ questionData ['question ' ] ?? '' ,
546549 'revision_id ' => 0 ,
547550 'author ' => $ this ->currentUser ->getUserData ('display_name ' ),
548551 'email ' => $ this ->currentUser ->getUserData ('email ' ),
549552 'comment ' => $ this ->configuration ->get (item: 'records.defaultAllowComments ' ) ? 'checked ' : null ,
550553 ];
551554
552555 $ categories = [
553- 'category_id ' => $ question ['category_id ' ],
556+ 'category_id ' => $ questionData ['category_id ' ] ?? [ ],
554557 'category_lang ' => $ faqLanguage ,
555558 ];
556559
@@ -568,8 +571,8 @@ public function answer(Request $request): Response
568571 'faqRevisionId ' => 0 ,
569572 'faqData ' => $ faqData ,
570573 'openQuestionId ' => 0 ,
571- 'notifyUser ' => $ question ['username ' ],
572- 'notifyEmail ' => $ question ['email ' ],
574+ 'notifyUser ' => $ questionData ['username ' ] ?? $ this -> currentUser -> getUserData ( ' display_name ' ) ,
575+ 'notifyEmail ' => $ questionData ['email ' ] ?? $ this -> currentUser -> getUserData ( ' email ' ) ,
573576 'categoryOptions ' => $ categoryHelper ->renderOptions ($ categories ),
574577 'languageOptions ' => LanguageHelper::renderSelectLanguage ($ faqLanguage , false , [], 'lang ' ),
575578 'attachments ' => [],
0 commit comments