#15089 closed defect (bug) (fixed)
wp_rand() can be asked for negative numbers but will never return them
Reported by: | hakre | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.1 | Priority: | lowest |
Severity: | minor | Version: | 2.6 |
Component: | General | Keywords: | good-first-bug has-patch commit |
Focuses: | docs | Cc: |
Description
wp_rand() has a min and a max parameter to address a wish which number to get back.
Unfourtionatly the function is unable to handle negative numbers w/o having this documented.
Change History (14)
#2
@
14 years ago
- Component changed from General to Inline Docs
- Milestone Awaiting Review deleted
- Priority changed from normal to lowest
- Resolution set to maybe later
- Severity changed from normal to trivial
- Status changed from new to closed
No patch and no traction closing for now.
#3
@
3 years ago
- Focuses docs added
- Keywords good-first-bug added
- Milestone set to Awaiting Review
- Resolution maybelater deleted
- Status changed from closed to reopened
- Version changed from 3.0 to 2.6
It's a little confusing that wp_rand()
will not return a negative integer. I think it would be worth adding a short note the function docs, especially now that it's mostly a wrapper of random_int()
, which will return negative integers.
This ticket was mentioned in PR #2305 on WordPress/wordpress-develop by Neychok.
3 years ago
#4
- Keywords has-patch added
A slight change in the wp_rand() docs indicating that it only returns non-negative numbers.
Trac ticket: https://core.trac.wordpress.org/ticket/15089
#6
@
2 years ago
- Component changed from Inline Docs to General
- Keywords needs-refresh added
- Milestone changed from Awaiting Review to 6.1
- Severity changed from trivial to minor
Thanks for creating a patch!
It needs to be refreshed after the commits on #55194.
This ticket was mentioned in PR #3265 on WordPress/wordpress-develop by Neychok.
2 years ago
#8
- Keywords needs-refresh removed
Changed the doc comment of the wp_rand()
function to indicate that it only returns positive numbers.
Trac ticket: https://core.trac.wordpress.org/ticket/15089
#9
@
2 years ago
Hey @desrosj, I just created a new PR with the updated patch. I closed the last one by mistake while syncing my fork.
I also changed the "A random non-negative number" to "A random positive number" from my last PR because at the time of my last PR the function was able to return a Zero.
Thank you for looking into this patch!
#10
@
2 years ago
Sorry for not being clear: the patch needed a refresh because lines around your changes were edited. The function can return zero (now), so "non-negative" should be correct.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
2 years ago
#12
@
2 years ago
- Keywords commit added
- Owner set to audrasjb
- Status changed from reopened to accepted
I added a commit to the above PR to replace "positive" with "non-negative".
Self assigning for commit
.
2 years ago
#14
Committed in https://core.trac.wordpress.org/changeset/54190
Related: #15090