#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
5 years ago
#5
committed in https://core.trac.wordpress.org/changeset/52645, thanks!
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
This PR fixes parameter/return value types for the
translations_api()function andtranslations_apiandtranslations_api_resulthooks fromobjecttoarray.Trac ticket: [](https://core.trac.wordpress.org/ticket/54959)