Skip to content

Commit

Permalink
Fix missing URLs prefixes
Browse files Browse the repository at this point in the history
* Fix fuzzy search URLs prefix
* Fix sublist URL prefix
  • Loading branch information
cedric-anne authored Jan 15, 2025
1 parent ec0e2a1 commit 376eb22
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -3541,12 +3541,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Html.php',
];
$ignoreErrors[] = [
'message' => '#^Method Html\\:\\:getMenuFuzzySearchList\\(\\) should return array\\{url\\: string, title\\: string\\} but returns list\\<array\\{url\\: mixed, title\\: mixed\\}\\>\\.$#',
'identifier' => 'return.type',
'count' => 1,
'path' => __DIR__ . '/src/Html.php',
];
$ignoreErrors[] = [
'message' => '#^Negated boolean expression is always true\\.$#',
'identifier' => 'booleanNot.alwaysTrue',
Expand Down
12 changes: 6 additions & 6 deletions src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -6093,7 +6093,7 @@ private static function getMiniFile($file_path)
*
* @return string
*/
final public static function getPrefixedUrl($url)
final public static function getPrefixedUrl(string $url): string
{
/** @var array $CFG_GLPI */
global $CFG_GLPI;
Expand Down Expand Up @@ -6139,7 +6139,7 @@ public static function manageRefreshPage($timer = false, $callback = null)
/**
* Get all options for the menu fuzzy search
* @return array
* @phpstan-return array{url: string, title: string}
* @phpstan-return array<array{url: string, title: string}>
* @since 11.0.0
*/
public static function getMenuFuzzySearchList(): array
Expand All @@ -6151,7 +6151,7 @@ public static function getMenuFuzzySearchList(): array
if (isset($firstlvl['default'])) {
if (strlen($firstlvl['title']) > 0) {
$fuzzy_entries[] = [
'url' => $firstlvl['default'],
'url' => self::getPrefixedUrl($firstlvl['default']),
'title' => $firstlvl['title']
];
}
Expand All @@ -6160,7 +6160,7 @@ public static function getMenuFuzzySearchList(): array
if (isset($firstlvl['default_dashboard'])) {
if (strlen($firstlvl['title']) > 0) {
$fuzzy_entries[] = [
'url' => $firstlvl['default_dashboard'],
'url' => self::getPrefixedUrl($firstlvl['default_dashboard']),
'title' => $firstlvl['title'] . " > " . __('Dashboard')
];
}
Expand All @@ -6170,15 +6170,15 @@ public static function getMenuFuzzySearchList(): array
foreach ($firstlvl['content'] as $menu) {
if (isset($menu['title']) && strlen($menu['title']) > 0) {
$fuzzy_entries[] = [
'url' => $menu['page'],
'url' => self::getPrefixedUrl($menu['page']),
'title' => $firstlvl['title'] . " > " . $menu['title']
];

if (isset($menu['options'])) {
foreach ($menu['options'] as $submenu) {
if (isset($submenu['title']) && strlen($submenu['title']) > 0) {
$fuzzy_entries[] = [
'url' => $submenu['page'],
'url' => self::getPrefixedUrl($submenu['page']),
'title' => $firstlvl['title'] . " > " .
$menu['title'] . " > " .
$submenu['title']
Expand Down
2 changes: 1 addition & 1 deletion templates/components/form/viewsubitem.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
modal_el[0].addEventListener('hidden.bs.modal', (event) => {
event.target.removeAttribute('data-cy-ready');
});
$('#{{ subitem_container_id }}').load('/ajax/viewsubitem.php',{
$('#{{ subitem_container_id }}').load('{{ path('/ajax/viewsubitem.php')|e('js') }}',{
type: "{{ type|e('js') }}",
parenttype: "{{ parenttype|e('js') }}",
{{ items_id }}: {{ id }},
Expand Down

0 comments on commit 376eb22

Please sign in to comment.