Skip to content

Ensured plain string first arguments for logging#28

Merged
jekuaitk merged 4 commits into
developfrom
feature/avoid-translations-of-logs
Apr 9, 2026
Merged

Ensured plain string first arguments for logging#28
jekuaitk merged 4 commits into
developfrom
feature/avoid-translations-of-logs

Conversation

@jekuaitk

@jekuaitk jekuaitk commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

Link to ticket

https://leantime.itkdev.dk/#/tickets/showTicket/7124

Description

  • Ensures first argument to logging are static string to avoid unintended translations.

Found by

grep -r -- "->\(emergency\|alert\|critical\|error\|warning\|notice\|info\|debug\|log\)([^']" .

Caution

The current set of package requirements cannot be installed from scratch. An issue discussing this has been created. We fully expect this to work in already installed installations, hence we ignore failed GitHub Actions right at this moment.

@jekuaitk jekuaitk requested a review from rimi-itk April 9, 2026 08:21

@rimi-itk rimi-itk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment on use of + with arrays.

try {
$this->helper->archive($payload['submissionId'], $payload['handlerConfiguration']);
$this->submissionLogger->notice($this->t('The submission #@serial was successfully delivered', ['@serial' => $webformSubmission->serial()]), $logger_context);
$this->submissionLogger->notice('The submission #@serial was successfully delivered', $logger_context + ['@serial' => $webformSubmission->serial()]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a real issue, but consider rewriting to

Suggested change
$this->submissionLogger->notice('The submission #@serial was successfully delivered', $logger_context + ['@serial' => $webformSubmission->serial()]);
$this->submissionLogger->notice('The submission #@serial was successfully delivered', ['@serial' => $webformSubmission->serial()] + $logger_context);

to make sure that you actually set the @serial key in the context. If $logger_context for some weird and unlikely reason already has a value for @serial, your value will be ignored (cf. https://www.php.net/manual/en/language.operators.array.php). See https://onlinephp.io/c/862da for an example.

@jekuaitk jekuaitk Apr 9, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considered and implemented in f323ee0!

@jekuaitk jekuaitk requested a review from rimi-itk April 9, 2026 10:24
@jekuaitk jekuaitk merged commit f323ee0 into develop Apr 9, 2026
5 of 11 checks passed
@jekuaitk jekuaitk deleted the feature/avoid-translations-of-logs branch April 9, 2026 10:30
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.

2 participants