Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#54959 closed defect (bug) (fixed)

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

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

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.


5 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
5 years ago

  • Component GeneralI18N
  • Milestone Awaiting Review6.0
  • Version 5.94.0

#3 @audrasjb
5 years ago

  • Owner set to audrasjb
  • Status newreviewing

#4 @audrasjb
5 years ago

  • Resolutionfixed
  • Status reviewingclosed

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:


5 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:


5 years ago
#7

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

Note: See TracTickets for help on using tickets.