#31553 closed defect (bug) (fixed)
number_format_i18n() can cause a PHP notice if $wp_locale is not set
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | low |
Severity: | minor | Version: | 2.3 |
Component: | I18N | Keywords: | has-patch |
Focuses: | Cc: |
Description
It is possible for number_format_i18n
to cause a PHP notice if called via timer_stop
at a point where $wp_locale
is not set.
This is because the function calls a method of the class without checking if it is available.
I attached a patch.
Attachments (1)
Change History (7)
#2
@
6 years ago
Drew,
Thanks for your comment. In my case I was calling timer_start()
and then timer_stop(1)
with some code in between to time it, directly on page load inside a plugin, not inside a hook and from the admin side.
Maybe this was not the expected use case for this function. However, would there not be some benefit to making the function a little more robust?
#4
@
6 years ago
- Priority changed from normal to low
- Severity changed from normal to minor
- Version changed from trunk to 2.3
This looks to me like it's existed since the function was introduced, so moving the version accordingly. If this really is a trunk issue somehow, please do let us know, although I don't think it's severe enough to worry about 4.2.
Hi Paul, thanks for the patch.
The only issue here is really that the function specifically serves to convert a number based on the locale. So while the
is_object()
check would solve the problem, I'd be curious to know what your use case is where$wp_locale
would not be set.