Files
Thomas Vincent e61d5e274a fix: declare __() before the disabled-i18n fallback returns (#7751)
* fix: declare __() before the disabled-i18n fallback returns

include/global_languages.php returns early to a fallback locale when
i18n_language_support is off. __() sits inside a function_exists() guard, and
PHP does not hoist a conditional declaration, so that return left __()
undefined for the rest of the request. The other translation helpers are plain
top level declarations, so hoisting covered them and only __() went missing.

include/global.php defines CACTI_VERSION_BRIEF through get_cacti_version_text()
on the next line, so the first caller was Cacti's own startup:

  PHP Fatal error: Uncaught Error: Call to undefined function __()
    in lib/functions.php:7975
  #0 lib/functions.php(8042): format_cacti_version_text()
  #1 include/global.php(700): get_cacti_version_text()
  #2 include/cli_check.php(54): include()
  #3 cli/install_cacti.php(26): require()

Reproduced against a freshly loaded schema, where the setting has no row and
no default yet because global_settings.php loads ten lines later. Before the
change cli/install_cacti.php dies at global.php:700; after it, startup clears
that line and continues.

The declaration moves above the fallback. Nothing else changes.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: address i18n fallback review

* docs: record the i18n bootstrap fix

* Fix translation helper guard formatting

* test: reuse the i18n fallback probe

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-08-17 23:52:43 -04:00
..