Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@steffunky
Copy link
Member

Base information

Question Answer
Related to a SourceForge thead / Another PR / Combodo ticket? N°7960
Type of change? Bug fix

Symptom (bug) / Objective (enhancement)

When a dictionary entry expects more arguments than they are passed in the code calling it (often a poor translation/mistake in the ITSM Designer), we get a ValueError crashing the application:

Uncaught ValueError: The arguments array must contain 2 items, 1 given in /core/valuesetdef.class.inc.php:438

Cause (bug)

This is expected as vsprintf since PHP 8.0 throws a ValueError if the number of arguments doesn't meet its needs.

Proposed solution (bug and enhancement)

This pull request add a wrapper in utils (as we did with EscapeHTML and HTMLEntities) in order to prevent a crash by creating placeholders as arguments and throwing a silent error.

If we have the following entry:

This object name is %1$s and its id is %2$s

But the code only provides as arguments [ 'Object name'], the generated string will be

This object name is Object name and its id is %2$s and we'll have an error in the logs

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have tested all changes I made on an iTop instance
  • I have added a unit test, otherwise I have explained why I couldn't
  • Is the PR clear and detailed enough so anyone can understand digging in the code?

@steffunky steffunky added this to the 3.2.2 milestone May 22, 2025
@CombodoApplicationsAccount CombodoApplicationsAccount added the internal Work made by Combodo label May 22, 2025
@steffunky steffunky requested review from bdalsass and jf-cbd May 22, 2025 09:04
@steffunky steffunky merged commit 9723cde into support/3.2 May 26, 2025
1 of 2 checks passed
@steffunky steffunky deleted the feature/7960_dict_format_robustness branch May 26, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants