Skip to content

Commit

Permalink
Fixing #5147 - Languages cause 500 error
Browse files Browse the repository at this point in the history
Error 500 on apache when changing languages
  • Loading branch information
TheWitness committed Jan 7, 2023
1 parent f8399c8 commit da8392a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -10,6 +10,7 @@ Cacti CHANGELOG
-issue#5142: Correct issues with permission model including display of authorization UI elements and warnings
-issue#5143: When a Device has zero Graphs or Data Sources, it does not display the correct value
-issue#5145: Changing SNMP settings to None leaves Bulk Walk Maximum Repititions visible
-issue#5147: Error 500 on apache when changing languages

1.2.23
-security#4920: Add .htaccess file to scripts folder
Expand Down
18 changes: 13 additions & 5 deletions include/global_languages.php
Expand Up @@ -504,23 +504,31 @@ function __() {
return __gettext($args[0]);

/* convert pure text strings by using a different textdomain */
} elseif ($num == 2 && isset($i18n[ (string) $args[1]]) && $args[1] != 'cacti') {
} elseif ($num == 2 && isset($i18n[(string)$args[1]]) && $args[1] != 'cacti') {
return __gettext($args[0], $args[1]);

/* convert stings including one or more placeholders */
} else {
/* only the last argument is allowed to initiate
the use of a different textdomain */

/* get gettext string */
if (isset($i18n[ (string) $args[$num-1]]) && $args[$num-1] != 'cacti') {
/* check plugin context */
if (isset($i18n[(string)$args[$num-1]]) && $args[$num-1] != 'cacti') {
$args[0] = __gettext($args[0], $args[$num-1]);
} else {
/* cacti context */
$args[0] = __gettext($args[0]);
}

/* process return string against input arguments */
return __uf(call_user_func_array('sprintf', $args));
$valid_args = array('%%', '%b', '%c', '%d', '%e', '%E', '%f', '%F', '%g', '%G', '%h', '%H', '%o', '%s', '%u', '%x', 'X');

if (array_search($args[0], $valid_args) !== false) {
/* process return string against input arguments */

return __uf(call_user_func_array('sprintf', $args));
} else {
return $args[0];
}
}
}

Expand Down

0 comments on commit da8392a

Please sign in to comment.