diff options
author | Thomas Lange <code@nerdmind.de> | 2021-06-14 20:03:19 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-06-14 20:03:19 +0200 |
commit | 78fcc20190121d487a2e6cf1fca53b66df67dc3a (patch) | |
tree | b9b0dc3da8afc923fbac80ade147305cb7079e3f /admin/post/update.php | |
parent | d453ba414803832bb4e4f9ae5eddec7ae3f60205 (diff) | |
download | blog-78fcc20190121d487a2e6cf1fca53b66df67dc3a.tar.gz blog-78fcc20190121d487a2e6cf1fca53b66df67dc3a.tar.xz blog-78fcc20190121d487a2e6cf1fca53b66df67dc3a.zip |
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".
Diffstat (limited to 'admin/post/update.php')
-rw-r--r-- | admin/post/update.php | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/admin/post/update.php b/admin/post/update.php index 7b82bf4..d7778f8 100644 --- a/admin/post/update.php +++ b/admin/post/update.php @@ -39,45 +39,36 @@ try { } } - #=============================================================================== - # 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' => 'UPDATE', - '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)); - $PostUpdateTemplate = Template\Factory::build('post/update'); - $PostUpdateTemplate->set('HTML', $FormTemplate); - - $MainTemplate = Template\Factory::build('main'); - $MainTemplate->set('NAME', $Language->text('title_post_update')); - $MainTemplate->set('HTML', $PostUpdateTemplate); - 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' => 'UPDATE', + 'INFO' => $messages ?? [], + 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER), + 'USER_LIST' => $userAttributes ?? [], + 'TOKEN' => Application::getSecurityToken() + ]); + + $PostUpdateTemplate = Template\Factory::build('post/update'); + $PostUpdateTemplate->set('HTML', $FormTemplate); + + $MainTemplate = Template\Factory::build('main'); + $MainTemplate->set('NAME', $Language->text('title_post_update')); + $MainTemplate->set('HTML', $PostUpdateTemplate); + echo $MainTemplate; } #=============================================================================== |