diff --git a/libraries/classes/Controllers/Triggers/IndexController.php b/libraries/classes/Controllers/Triggers/IndexController.php
index c6bc2a8de1..2374fd3c02 100644
--- a/libraries/classes/Controllers/Triggers/IndexController.php
+++ b/libraries/classes/Controllers/Triggers/IndexController.php
@@ -73,6 +73,31 @@ final class IndexController extends AbstractController
*/
$GLOBALS['errors'] = [];
- $this->triggers->main();
+ $this->triggers->handleEditor();
+ $this->triggers->export();
+
+ $items = Triggers::getDetails($this->dbi, $GLOBALS['db'], $GLOBALS['table']);
+ $hasTriggerPrivilege = Util::currentUserHasPrivilege('TRIGGER', $GLOBALS['db'], $GLOBALS['table']);
+ $isAjax = $this->response->isAjax() && empty($_REQUEST['ajax_page_request']);
+
+ $rows = '';
+ foreach ($items as $item) {
+ $rows .= $this->template->render('triggers/row', [
+ 'db' => $GLOBALS['db'],
+ 'table' => $GLOBALS['table'],
+ 'trigger' => $item,
+ 'has_drop_privilege' => $hasTriggerPrivilege,
+ 'has_edit_privilege' => $hasTriggerPrivilege,
+ 'row_class' => $isAjax ? 'ajaxInsert hide' : '',
+ ]);
+ }
+
+ $this->render('triggers/list', [
+ 'db' => $GLOBALS['db'],
+ 'table' => $GLOBALS['table'],
+ 'items' => $items,
+ 'rows' => $rows,
+ 'has_privilege' => $hasTriggerPrivilege,
+ ]);
}
}
diff --git a/libraries/classes/Triggers/Triggers.php b/libraries/classes/Triggers/Triggers.php
index 6a315330cb..fb1ab58702 100644
--- a/libraries/classes/Triggers/Triggers.php
+++ b/libraries/classes/Triggers/Triggers.php
@@ -44,42 +44,6 @@ class Triggers
) {
}
- /**
- * Main function for the triggers functionality
- */
- public function main(): void
- {
- /**
- * Process all requests
- */
- $this->handleEditor();
- $this->export();
-
- $items = self::getDetails($this->dbi, $GLOBALS['db'], $GLOBALS['table']);
- $hasTriggerPrivilege = Util::currentUserHasPrivilege('TRIGGER', $GLOBALS['db'], $GLOBALS['table']);
- $isAjax = $this->response->isAjax() && empty($_REQUEST['ajax_page_request']);
-
- $rows = '';
- foreach ($items as $item) {
- $rows .= $this->template->render('triggers/row', [
- 'db' => $GLOBALS['db'],
- 'table' => $GLOBALS['table'],
- 'trigger' => $item,
- 'has_drop_privilege' => $hasTriggerPrivilege,
- 'has_edit_privilege' => $hasTriggerPrivilege,
- 'row_class' => $isAjax ? 'ajaxInsert hide' : '',
- ]);
- }
-
- echo $this->template->render('triggers/list', [
- 'db' => $GLOBALS['db'],
- 'table' => $GLOBALS['table'],
- 'items' => $items,
- 'rows' => $rows,
- 'has_privilege' => $hasTriggerPrivilege,
- ]);
- }
-
/**
* Handles editor requests for adding or editing an item
*/
@@ -469,7 +433,7 @@ class Triggers
echo $message->getDisplay();
}
- private function export(): void
+ public function export(): void
{
if (empty($_GET['export_item']) || empty($_GET['item_name'])) {
return;
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 270ff0f8a4..d089ffdc52 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -4311,10 +4311,11 @@
+ $item
-
+
$request
-
+
@@ -12943,7 +12944,6 @@
$createItem
$exportData
- $item
diff --git a/test/classes/Controllers/Triggers/IndexControllerTest.php b/test/classes/Controllers/Triggers/IndexControllerTest.php
index b6317c981d..12ad7c9c64 100644
--- a/test/classes/Controllers/Triggers/IndexControllerTest.php
+++ b/test/classes/Controllers/Triggers/IndexControllerTest.php
@@ -78,13 +78,14 @@ class IndexControllerTest extends AbstractTestCase
'has_edit_privilege' => true,
'row_class' => '',
]);
-
- $this->expectOutputString($template->render('triggers/list', [
+ $expected = $template->render('triggers/list', [
'db' => $GLOBALS['db'],
'table' => $GLOBALS['table'],
'items' => $items,
'rows' => $rows,
'has_privilege' => true,
- ]));
+ ]);
+
+ $this->assertSame($expected, $response->getHTMLResult());
}
}