Skip to content
Snippets Groups Projects

Issue #3432768: use an empty string instead of null

1 unresolved thread

Closes #3432768

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
268 268 $this->normalizeHeaders($message);
269 269 if (!empty($message['headers']) && is_array($message['headers'])) {
270 270 foreach ($message['headers'] as $header_key => $header_value) {
271 $header_value = $header_value ?? '';
271 272 if (empty($header_key) || in_array($header_key, $headers_to_skip, FALSE)) {
272 273 continue;
273 274 }
  • Comment on lines 270 to 273

    That approach wouldn't help, since it would e.g. try to create an address from an empty string, which would then lead to a different exception.

    Instead, the whole loop should probably be skipped for empty header values. Something like this:

    Suggested change
    269 foreach ($message['headers'] as $header_key => $header_value) {
    270 $header_value = $header_value ?? '';
    271 if (empty($header_key) || in_array($header_key, $headers_to_skip, FALSE)) {
    272 continue;
    273 }
    269 foreach ($message['headers'] as $header_key => $header_value) {
    270 if (empty($header_value) || empty($header_key) || in_array($header_key, $headers_to_skip, FALSE)) {
    271 continue;
    272 }
  • Got it, thanks, makes sense.

    Edited by aaron.ferris
  • Please register or sign in to reply
  • aaron.ferris added 1 commit

    added 1 commit

    Compare with previous version

  • Wayne Eaker added 3 commits

    added 3 commits

    Compare with previous version

  • merged

  • Please register or sign in to reply
    Loading