From 69c6b6f2ac769c2864117dc1417e246427fc7e80 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 15 Jul 2023 02:14:39 +0000 Subject: [PATCH] Fixed various other oversights. --- public/_github-callback.php | 17 +++++++---------- public/manage/changelog/change.php | 30 ++++++++++++++++-------------- src/Changelog/ChangelogChange.php | 12 ------------ templates/changelog/change.twig | 4 ++-- 4 files changed, 25 insertions(+), 38 deletions(-) delete mode 100644 src/Changelog/ChangelogChange.php diff --git a/public/_github-callback.php b/public/_github-callback.php index 140cfa3..3946f2f 100644 --- a/public/_github-callback.php +++ b/public/_github-callback.php @@ -1,9 +1,6 @@ = 10 ? $line : mb_substr($line, $findColon + 1)); } -function ghcb_changelog_action(string &$line): int { +function ghcb_changelog_action(string &$line): string { $original = trim($line); $line = ghcb_strip_prefix($line); @@ -20,17 +17,17 @@ function ghcb_changelog_action(string &$line): int { if($firstSix === 'revert' || $firstSix === 'restor') - return ChangelogChange::ACTION_REVERT; + return 'revert'; if($firstSix === 'import') - return ChangelogChange::ACTION_IMPORT; + return 'import'; $firstThree = mb_strtolower(mb_substr($original, 0, 3)); if($firstThree === 'add' || $firstSix === 'create') - return ChangelogChange::ACTION_ADD; + return 'add'; if($firstThree === 'fix') - return ChangelogChange::ACTION_FIX; + return 'fix'; $firstFour = mb_strtolower(mb_substr($original, 0, 4)); $firstEight = mb_strtolower(mb_substr($original, 0, 8)); @@ -39,9 +36,9 @@ function ghcb_changelog_action(string &$line): int { || $firstSix === 'remove' || $firstFour === 'nuke' || $firstEight === 'dropkick') - return ChangelogChange::ACTION_REMOVE; + return 'remove'; - return ChangelogChange::ACTION_UPDATE; + return 'update'; } header('Content-Type: text/plain; charset=utf-8'); diff --git a/public/manage/changelog/change.php b/public/manage/changelog/change.php index 70eb134..8a2821a 100644 --- a/public/manage/changelog/change.php +++ b/public/manage/changelog/change.php @@ -82,23 +82,25 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) { $changelog->updateChange($changeInfo, $action, $summary, $body, $updateUserInfo, $userId, $createdAt); } - $tCurrent = $changeInfo->getTagIds(); - $tApply = $tags; - $tRemove = []; + if(!empty($tags)) { + $tCurrent = $changeInfo->getTagIds(); + $tApply = $tags; + $tRemove = []; - foreach($tCurrent as $tag) - if(!in_array($tag, $tApply)) { - $tRemove[] = $tag; - $changelog->removeTagFromChange($changeInfo, $tag); - } + foreach($tCurrent as $tag) + if(!in_array($tag, $tApply)) { + $tRemove[] = $tag; + $changelog->removeTagFromChange($changeInfo, $tag); + } - $tCurrent = array_diff($tCurrent, $tRemove); + $tCurrent = array_diff($tCurrent, $tRemove); - foreach($tApply as $tag) - if(!in_array($tag, $tCurrent)) { - $changelog->addTagToChange($changeInfo, $tag); - $tCurrent[] = $tag; - } + foreach($tApply as $tag) + if(!in_array($tag, $tCurrent)) { + $changelog->addTagToChange($changeInfo, $tag); + $tCurrent[] = $tag; + } + } AuditLog::create( $isNew ? AuditLog::CHANGELOG_ENTRY_CREATE : AuditLog::CHANGELOG_ENTRY_EDIT, diff --git a/src/Changelog/ChangelogChange.php b/src/Changelog/ChangelogChange.php deleted file mode 100644 index 74ba9a4..0000000 --- a/src/Changelog/ChangelogChange.php +++ /dev/null @@ -1,12 +0,0 @@ - {% for tag in change_info.tags %}
  • - + {{ tag.name }}
  • @@ -60,7 +60,7 @@

    {{ title }}

    {% if change_info.hasBody %} - {{ change_info.parsedBody|raw }} + {{ change_info.body|parse_text(2)|raw }} {% else %}

    This change has no additional notes.

    {% endif %}