[wp-trac] [WordPress Trac] #63175: Tests: Improve Unit tests for 'wp_unique_id_from_values()'

WordPress Trac noreply at wordpress.org
Tue Mar 25 18:47:50 UTC 2025


#63175: Tests: Improve Unit tests for 'wp_unique_id_from_values()'
--------------------------+-------------------------
 Reporter:  joemcgill     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  6.8
Component:  General       |    Version:
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:  tests         |
--------------------------+-------------------------
 A new function, `wp_unique_id_from_values()` and related unit tests were
 added in [60038]. The tests assume that the unique ID will always produce
 a consistent hash output regardless of hosting environment, due to the way
 the `wp_json_encode()` and the `md5()` algorithm works.

 However, some hosting environments are reporting test failures due to a
 different unique hash being produced.

 Examples:

 - https://make.wordpress.org/hosting/test-
 results/r60038/bluehostbot-r60038-8-0-mysql-ver-14-14-distrib-5-7-23-23
 -for-linux-x86_64-using-6-2/
 - https://make.wordpress.org/hosting/test-
 results/r60038/bluehostbot-r60038-8-3-mysql-ver-14-14-distrib-5-7-23-23
 -for-linux-x86_64-using-6-2/
 - https://make.wordpress.org/hosting/test-
 results/r60040/xserverbot-r60040-7-4-mysql-ver-15-1-distrib-10-5-22
 -mariadb-for-linux-x86_64-using-editline-wrapper/

 In this case, I believe the unit tests are likely assuming too much by
 expecting a specific hash output, and instead should be revised to assert
 that the same data passed multiple times will result in the same value
 each time, and that it will be different than an different value passed to
 the same function.

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


More information about the wp-trac mailing list