[wp-trac] [WordPress Trac] #61936: wp_get_object_terms: Unexpected return type (PHP 7.4)/fatal error (PHP 8.0+) when requesting a count

WordPress Trac noreply at wordpress.org
Tue Aug 27 13:46:36 UTC 2024


#61936: wp_get_object_terms: Unexpected return type (PHP 7.4)/fatal error (PHP
8.0+) when requesting a count
--------------------------+-----------------------------
 Reporter:  marian1       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  6.6.1
 Severity:  major         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Similar to `get_terms()`, which is called by `wp_get_object_terms()`, and
 as outlined in the return type description, `wp_get_object_terms()` should
 return a count of terms as a numeric string when `$args = array('fields'
 => 'count')`. However, requesting a count for an existing object and valid
 taxonomy results in `wp_get_object_terms()` returning `null` and
 triggering a warning on PHP 7.4, and causing a fatal error on PHP 8.0+.

 This issue is caused by the use of the return value of `get_terms()`,
 which is a numeric string for `$args = array('fields' => 'count')`, in
 `array_merge()`. See
 [https://core.trac.wordpress.org/browser/tags/6.6.1/src/wp-
 includes/taxonomy.php#L2316-L2323 lines 2316-2323 in src/wp-
 includes/taxonomy.php].

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61936>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list