Inconsistent Variable Usage
|Reported by:||ericmann||Owned by:||ericmann|
Someone in the forums alerted me to a potential issue with the code in wp_version_check(). It seems we're using two different functions to get a user count depending on whether we're in Multisite or a standalone installation.
The Multisite function (get_user_count()) returns a number. The standalone function (count_users()) returns an array. We then assume the array when we use the variable later to build the version check query.
In some situations, this can result in an "illegal string offset" error.
In other situations, it will generate inaccurate data. Assume the following situation:
- get_user_count() returns "100" because there are 100 users.
- $user_count['total_users'] will return "1"
When you reference a string as an array with an offset that doesn't exist, it only returns the first digit. So our count, in this case, is only accurate for Multisite installations with 1-9 users.
Not a huge end-user issue ... but confusing for WP.org stats in the long run if it remains unpatched.
I have worked out a patch that will fix the stat reporting issue for us and silence any "illegal string offset" issues other developers might be experiencing.
Change History (12)
comment:2 @SergeyBiryukov — 3 years ago
- Keywords commit added
- Milestone changed from Awaiting Review to 3.4.1
- Version changed from 3.4 to 3.1