`front/config.form.php`: `$CFG_GLPI` used without `global` (undefined variable warning, wrong redirect when GLPI is in a subdirectory)
Bewertung
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Anfängerfreundlichkeit
- 89/100
Rechercherichtung
Öffne front/config.form.php und prüfe den abschließenden else-Zweig, der den direkten Zugriff auf die Plugin-Konfigurationsseite behandelt. Deklariere dort $CFG_GLPI als global und überprüfe anschließend, dass die Weiterleitung dessen root_doc-Wert verwendet und die Warnungen über die undefinierte Variable nicht mehr protokolliert. Laut Issue funktioniert die Korrektur mit GLPI 11.0.12; eine Testdatei wird nicht erwähnt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
GLPI Version
11.0.12 (also reproducible on 11.0.11)
Plugin version
1.4.3 — same code in 1.5.0 and on main/develop as of 2026-10-29
Bug description
The final else branch of front/config.form.php uses $CFG_GLPI without declaring it global:
} else {
Session::checkRight(Config::$rightname, READ);
/** @var array $CFG_GLPI */
Html::redirect($CFG_GLPI['root_doc'] . '/front/config.form.php?forcetab=PluginMetabaseConfig$1');
}
Since GLPI 11, legacy front/ scripts are included from inside a method (Glpi\Controller\LegacyFileLoadController::__invoke()), so they no longer run in the global scope and $CFG_GLPI is null there unless it is declared with global. The @var annotation documents the variable but does not import it.
Consequences when the plugin configuration page is opened directly (e.g. the "configure" icon in Setup > Plugins, which points to plugins/metabase/front/config.form.php):
- Two PHP warnings are written to
php-errors.logon every access (see log below). $CFG_GLPI['root_doc']evaluates tonull, so the redirect target becomes/front/config.form.php?.... This happens to work when GLPI is served at the web root, but on an instance installed in a subdirectory (for examplehttps://example.org/glpi, whereroot_docis/glpi) the browser is sent outside of GLPI and the configuration page cannot be reached from that link.
Expected: no warning, and a redirect to <root_doc>/front/config.form.php?forcetab=PluginMetabaseConfig$1.
Suggested fix (one line, same pattern used elsewhere in GLPI plugins):
} else {
Session::checkRight(Config::$rightname, READ);
/** @var array $CFG_GLPI */
+ global $CFG_GLPI;
Html::redirect($CFG_GLPI['root_doc'] . '/front/config.form.php?forcetab=PluginMetabaseConfig$1');
}
We applied exactly this change locally on a production GLPI 11.0.12 instance: the warnings disappear and the redirect lands on the Metabase configuration tab as expected.
Relevant log output
[2026-10-29 15:38:22] glpi.WARNING: *** Warning: Undefined variable $CFG_GLPI at config.form.php line 51
Backtrace :
./marketplace/metabase/front/config.form.php:51
...Glpi/Controller/LegacyFileLoadController.php:64 require()
./vendor/symfony/http-kernel/HttpKernel.php:181 Glpi\Controller\LegacyFileLoadController->__invoke()
./vendor/symfony/http-kernel/HttpKernel.php:76 Symfony\Component\HttpKernel\HttpKernel->handleRaw()
./vendor/symfony/http-kernel/Kernel.php:208 Symfony\Component\HttpKernel\HttpKernel->handle()
[2026-10-29 15:38:22] glpi.WARNING: *** Warning: Trying to access array offset on value of type null at config.form.php line 51
Page URL
/plugins/metabase/front/config.form.php (no parameters)
Steps To reproduce
- Install and enable the Metabase plugin on GLPI 11.
- Log in as a user with
configREAD right. - Open
plugins/metabase/front/config.form.phpdirectly (or click the plugin's configure icon in Setup > Plugins). - Check
files/_log/php-errors.log: the two warnings above are logged. - On an instance where GLPI is installed in a subdirectory, observe that the redirect goes to
/front/config.form.php(outside of the GLPI path) instead of<root_doc>/front/config.form.php.
Your GLPI setup information
- PHP 8.2.35, Apache 2.4 (mod_php), Debian 12
- MariaDB 10.11.19
- GLPI installed at the web root (
root_docempty), so only the warnings are visible on our side; the wrong redirect follows from the code for subdirectory installs.
- Vorherrschende Sprache
- PHP
- Sterne
- 17
- Forks
- 12
- Ø Merge
- 1 Std. 47 Min.
- Gemergte PRs (30 T.)
- 5
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus pluginsGLPI/metabase
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
pluginsGLPI/metabase#171 · 1 Kommentar ·
Alle Issues in pluginsGLPI/metabase
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removedEvtl. vergeben @pcvelz hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
OpenMage/magento-lts#5869 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 85/100
modelcontextprotocol/php-sdk#746 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Map Info Window ButtonsOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
OpenGIS/waymark-wp#82 ·