Fixed various other oversights.

This commit is contained in:
flash 2023-07-15 02:14:39 +00:00
parent c56617e051
commit 69c6b6f2ac
4 changed files with 25 additions and 38 deletions

View file

@ -1,9 +1,6 @@
<?php
namespace Misuzu;
use Misuzu\DB;
use Misuzu\Changelog\ChangelogChange;
$misuzuBypassLockdown = true;
require_once '../misuzu.php';
@ -12,7 +9,7 @@ function ghcb_strip_prefix(string $line): string {
return trim($findColon === false || $findColon >= 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');

View file

@ -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,

View file

@ -1,12 +0,0 @@
<?php
namespace Misuzu\Changelog;
class ChangelogChange {
public const ACTION_UNKNOWN = 0;
public const ACTION_ADD = 1;
public const ACTION_REMOVE = 2;
public const ACTION_UPDATE = 3;
public const ACTION_FIX = 4;
public const ACTION_IMPORT = 5;
public const ACTION_REVERT = 6;
}

View file

@ -46,7 +46,7 @@
<ul class="changelog__change__tags">
{% for tag in change_info.tags %}
<li class="changelog__change__tag" title="{{ tag.description }}">
<a href="{{ url('changelog-tag', {'tag': tag.id}) }}" class="changelog__change__tag__link">
<a href="{{ url('changelog-index', {'tags': tag.id}) }}" class="changelog__change__tag__link">
{{ tag.name }}
</a>
</li>
@ -60,7 +60,7 @@
<h1>{{ title }}</h1>
{% if change_info.hasBody %}
{{ change_info.parsedBody|raw }}
{{ change_info.body|parse_text(2)|raw }}
{% else %}
<p>This change has no additional notes.</p>
{% endif %}