From 78fcc20190121d487a2e6cf1fca53b66df67dc3a Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 14 Jun 2021 20:03:19 +0200 Subject: Remove more redundant try/catch blocks Remove all try/catch blocks where the exception handling did not differ from the exception handler already defined by "set_exception_handler". --- admin/post/insert.php | 59 ++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 34 deletions(-) (limited to 'admin/post/insert.php') diff --git a/admin/post/insert.php b/admin/post/insert.php index 6916a61..6065c95 100644 --- a/admin/post/insert.php +++ b/admin/post/insert.php @@ -37,42 +37,33 @@ if(HTTP::issetPOST('id', 'user', 'slug', 'name', 'body', 'argv', 'time_insert', } } -#=============================================================================== -# TRY: Template\Exception -#=============================================================================== -try { - $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE)); - - foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) { - $User = User\Factory::build($userID); - $userAttributes[] = [ - 'ID' => $User->attr('id'), - 'FULLNAME' => $User->attr('fullname'), - 'USERNAME' => $User->attr('username'), - ]; - } - - $FormTemplate = Template\Factory::build('post/form'); - $FormTemplate->set('FORM', [ - 'TYPE' => 'INSERT', - 'INFO' => $messages ?? [], - 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER), - 'USER_LIST' => $userAttributes ?? [], - 'TOKEN' => Application::getSecurityToken() - ]); +$userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE)); - $InsertTemplate = Template\Factory::build('post/insert'); - $InsertTemplate->set('HTML', $FormTemplate); - - $MainTemplate = Template\Factory::build('main'); - $MainTemplate->set('NAME', $Language->text('title_post_insert')); - $MainTemplate->set('HTML', $InsertTemplate); - echo $MainTemplate; +foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) { + $User = User\Factory::build($userID); + $userAttributes[] = [ + 'ID' => $User->attr('id'), + 'FULLNAME' => $User->attr('fullname'), + 'USERNAME' => $User->attr('username'), + ]; } #=============================================================================== -# CATCH: Template\Exception +# Build document #=============================================================================== -catch(Template\Exception $Exception) { - Application::exit($Exception->getMessage()); -} +$FormTemplate = Template\Factory::build('post/form'); +$FormTemplate->set('FORM', [ + 'TYPE' => 'INSERT', + 'INFO' => $messages ?? [], + 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER), + 'USER_LIST' => $userAttributes ?? [], + 'TOKEN' => Application::getSecurityToken() +]); + +$InsertTemplate = Template\Factory::build('post/insert'); +$InsertTemplate->set('HTML', $FormTemplate); + +$MainTemplate = Template\Factory::build('main'); +$MainTemplate->set('NAME', $Language->text('title_post_insert')); +$MainTemplate->set('HTML', $InsertTemplate); +echo $MainTemplate; -- cgit v1.2.3