1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/16010] Enforce alphabetical order for events in events.md

PHPBB3-16010
This commit is contained in:
Marc Alexander
2019-04-04 22:16:37 +02:00
parent cc7c1c8447
commit c3ecaa35cd
2 changed files with 234 additions and 226 deletions

View File

@@ -143,6 +143,8 @@ class md_exporter
list($event_name, $details) = explode("\n===\n", $event, 2);
$this->validate_event_name($event_name);
$sorted_events = [$this->current_event, $event_name];
natsort($sorted_events);
$this->current_event = $event_name;
if (isset($this->events[$this->current_event]))
@@ -150,6 +152,12 @@ class md_exporter
throw new \LogicException("The event '{$this->current_event}' is defined multiple times");
}
// Use array_values() to get actual first element and check against natural order
if (array_values($sorted_events)[0] === $event_name)
{
throw new \LogicException("The event '{$sorted_events[1]}' should be defined before '{$sorted_events[0]}'");
}
if (($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0)
|| ($this->filter == 'styles' && strpos($this->current_event, 'acp_') === 0))
{