Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#54586 closed defect (bug) (fixed)

Avoid translating empty plugin headers

Reported by: chouby's profile Chouby Owned by: audrasjb's profile audrasjb
Milestone: 6.0 Priority: normal
Severity: trivial Version: 3.4
Component: I18N Keywords: has-patch commit assigned-for-commit
Focuses: Cc:

Description

WPCS recommends not to translate empty strings. On the other hand, plugin headers may not all be filled, but since #19597, _get_plugin_data_markup_translate() translates them all whether they are empty or not.

I propose to check that the string is not empty before attempting to translate it.

Attachments (1)

54586.patch (981 bytes) - added by Chouby 2 years ago.

Download all attachments as: .zip

Change History (9)

@Chouby
2 years ago

#1 @johnbillion
2 years ago

  • Keywords reporter-feedback added

@Chouby Could you provide an example of a plugin header that results in empty strings being translated? Thanks!

#3 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 6.0

#5 @audrasjb
2 years ago

  • Keywords commit assigned-for-commit added

Looks good to me. I added a PR to run the unit tests, and then it should be good to go.

#6 @audrasjb
2 years ago

  • Owner set to audrasjb
  • Status changed from new to reviewing

#7 @audrasjb
2 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 53181:

Plugins: Avoid translating empty plugin headers.

This change aims to avoid unnecessarily translating empty strings from plugin headers, by removing empty fields from translation process in _get_plugin_data_markup_translate().

Props Chouby, johnbillion, audrasjb.
Fixes #54586.

Note: See TracTickets for help on using tickets.