Skip to content

Fix 'Undefined array key completed' warning in Platform Order Decorator#585

Open
proteusbr1 wants to merge 1 commit intopagarme:masterfrom
proteusbr1:fix/undefined-array-key-completed
Open

Fix 'Undefined array key completed' warning in Platform Order Decorator#585
proteusbr1 wants to merge 1 commit intopagarme:masterfrom
proteusbr1:fix/undefined-array-key-completed

Conversation

@proteusbr1
Copy link
Copy Markdown

Qual o tipo de PR é esse? (marque todos os aplicáveis)

  • Refatoração
  • Adição de funcionalidade
  • Correção de bug
  • Otimização
  • Atualização de documentação

Descrição

Este PR corrige um Warning: Undefined array key "completed" que ocorria quando o método getState recebia um status do WooCommerce que não estava mapeado (neste caso, completed).

Alterações realizadas:

  • Adicionado o status completed => complete ao array $statusToState.
  • Implementado operator null coalescing (??) como fallback seguro. Caso o plugin receba um status desconhecido no futuro, ele retornará 'processing' em vez de gerar um Warning.

Cenários testados

  • Cenário de Erro: Verificado que o status completed agora é mapeado corretamente e status desconhecidos não geram mais warnings.

This commit adds the missing 'completed' status to the status-to-state mapping and implements a safe fallback using the null coalescing operator. This prevents warnings when unknown statuses are encountered.
Copilot AI review requested due to automatic review settings January 2, 2026 16:45
@backstage-catalog-validator
Copy link
Copy Markdown

⚠️ Este repositório ainda não está catalogado no Backstage. ⚠️

Por favor, catalogue-o seguindo as instruções nesta documentação. [Via VPN].

💁 Qualquer problema ou dúvida, estamos no Slack, basta abrir um ticket no canal #help-foundation-platform.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a PHP warning that occurred when the getState() method received the WooCommerce 'completed' status, which was not mapped in the status-to-state conversion array.

Key changes:

  • Added mapping for WooCommerce 'completed' status to 'complete' state
  • Replaced incorrectly used ternary operator with null coalescing operator for safer fallback handling
  • Added trailing comma to last array element following PHP best practices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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