Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54959 closed defect (bug) (fixed)

Incorrect type in docblock for `translations_api` and `translations_api_result` hooks

Reported by: volodymyrkolesnykov's profile volodymyrkolesnykov Owned by: audrasjb's profile audrasjb
Milestone: 6.0 Priority: normal
Severity: normal Version: 4.0
Component: I18N Keywords: has-patch
Focuses: docs Cc:

Description

translation_api and translation_api_result filters are incorrectly marked as taking object as their first argument (https://github.com/WordPress/WordPress/blob/5.9/wp-admin/includes/translation-install.php#L32, https://github.com/WordPress/WordPress/blob/5.9/wp-admin/includes/translation-install.php#L105).

The correct type should be array (https://github.com/WordPress/WordPress/blob/5.9/wp-admin/includes/translation-install.php#L85), as json_decode() is asked to return an associative array; moreover, the code checks that the result is an array (https://github.com/WordPress/WordPress/blob/5.9/wp-admin/includes/translation-install.php#L86), and consumers of translations_api() also expect to see an array (https://github.com/WordPress/WordPress/blob/5.9/wp-admin/includes/translation-install.php#L135).

Change History (7)

This ticket was mentioned in PR #2234 on WordPress/wordpress-develop by sjinks.


3 years ago
#1

  • Keywords has-patch added

This PR fixes parameter/return value types for the translations_api() function and translations_api and translations_api_result hooks from object to array.

Trac ticket: [](https://core.trac.wordpress.org/ticket/54959)

#2 @audrasjb
3 years ago

  • Component changed from General to I18N
  • Milestone changed from Awaiting Review to 6.0
  • Version changed from 5.9 to 4.0

#3 @audrasjb
3 years ago

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

#4 @audrasjb
3 years ago

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

In 52645:

Docs: Fix incorrect type in translations_api and translations_api_result docblocks.

Before this changeset, translation_api and translation_api_result filters were incorrectly marked as taking object as their first argument. The correct type is an array as json_decode() is asked to return an associative array.

Props volodymyrkolesnykov.
Fixes #54959.

valerio-bozzolan commented on PR #2234:


3 years ago
#6

Sorry for this question but how can someone from https://core.trac.wordpress.org/changeset/52645 discover the original author (that is @sjinks and not @audrasjb)? Just for my curiosity.

sjinks commented on PR #2234:


3 years ago
#7

@valerio-bozzolan "props volodymyrkolesnykov" in the commit message 🙂

Note: See TracTickets for help on using tickets.