Skip to content

Fix undefined $CFG_GLPI in front/config.form.php - #167

Open
whamulti wants to merge 1 commit into
pluginsGLPI:mainfrom
whamulti:fix/config-form-cfg-glpi-global
Open

whamulti wants to merge 1 commit into
pluginsGLPI:mainfrom
whamulti:fix/config-form-cfg-glpi-global

Conversation

@whamulti

Copy link
Copy Markdown
Contributor

Fixes #166

Since GLPI 11, legacy front/ scripts are included from inside Glpi\Controller\LegacyFileLoadController::__invoke(), so they no longer run in the global scope. The final else branch of front/config.form.php used $CFG_GLPI without declaring it global (the @var annotation only documents it), which caused:

  • two PHP warnings in php-errors.log on every direct access (Undefined variable $CFG_GLPI and Trying to access array offset on value of type null, line 51);
  • root_doc evaluating to null, so the redirect went to /front/config.form.php — outside of GLPI for instances installed in a subdirectory.

Changes

  • front/config.form.php: add global $CFG_GLPI; before the redirect.
  • CHANGELOG.md: entry under [Unreleased].

Tested

Same one-line change applied on a production GLPI 11.0.12 instance (plugin 1.4.3, same code as main): opening plugins/metabase/front/config.form.php now redirects to the Metabase configuration tab and no warning is logged.

🤖 Generated with Claude Code

Since GLPI 11, legacy front/ scripts are included from inside
LegacyFileLoadController::__invoke(), so they no longer run in the
global scope. The final else branch used $CFG_GLPI without declaring
it global: two PHP warnings were logged on every direct access and
root_doc evaluated to null, sending instances installed in a
subdirectory to /front/config.form.php outside of GLPI.

Fixes pluginsGLPI#166

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

front/config.form.php: $CFG_GLPI used without global (undefined variable warning, wrong redirect when GLPI is in a subdirectory)

1 participant