WordPress.org

Make WordPress Core

Opened 23 months ago

Last modified 3 months ago

#20854 reopened defect (bug)

functions.php on line 155 ?

Reported by: leondari Owned by: Nikolaos Raftopoulos
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.3.2
Component: Users Keywords: has-patch
Focuses: multisite Cc:

Description

In my network dashboard I get the following error message :

Warning: number_format() expects parameter 1 to be double, string given in /home/tklighth/public_html/wp-includes/functions.php on line 155

Attachments (2)

20854.diff (753 bytes) - added by kobenland 23 months ago.
Wraps $count in absint()
20854.2.diff (758 bytes) - added by jeremyfelt 8 months ago.

Download all attachments as: .zip

Change History (12)

comment:1 scribu23 months ago

  • Keywords reporter-feedback added; needs-codex needs-testing removed

Install this in your mu-plugins folder to get more information about the error:

https://raw.github.com/gist/625769/e26b3eb9b5ccaeeda75dc266fdbd6f8e36da51f5/backtrace-errors.php

comment:3 kobenland23 months ago

I have the same warning in my 3.3.2 (and prior) install, but I can't seem to reproduce it in 3.4-RC2.

The number of users are stored in a site option, which is fed by a query returning a string:

//in wp-includes/ms-functions.php line 1980
$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") );
update_site_option( 'user_count', $count );

kobenland23 months ago

Wraps $count in absint()

comment:4 SergeyBiryukov21 months ago

I can reproduce in 3.4.1 with a custom user table which doesn't contain spam and deleted fields.
wp_update_network_counts() then fails to update user_count site meta value:

SELECT COUNT(ID) as c FROM wp_users WHERE spam = '0' AND deleted = '0'
Unknown column 'spam' in 'where clause'

user_count ends up being an empty string, which leads to the notice.

jeremyfelt8 months ago

comment:5 jeremyfelt8 months ago

  • Keywords has-patch added; reporter-feedback removed
  • Milestone changed from Awaiting Review to 3.7

20854.2.diff is a refresh against trunk. Wraps blog and user counts in absint() before setting the options.

comment:6 follow-up: nacin8 months ago

I'm not sure what this does. When the option comes back out of the table, it'll again be a string.

If the issue is to paper over an issue where a custom user table is missing the spam and deleted fields, that sounds like a much larger issue, and we shouldn't be papering over it with an int cast in this one situation.

comment:7 in reply to: ↑ 6 SergeyBiryukov8 months ago

  • Milestone 3.7 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Replying to nacin:

If the issue is to paper over an issue where a custom user table is missing the spam and deleted fields, that sounds like a much larger issue, and we shouldn't be papering over it with an int cast in this one situation.

Indeed.

comment:8 nacin8 months ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

I don't think this means it is a wontfix right away — we should audit core to see what happens when these fields are missing.

comment:9 SergeyBiryukov8 months ago

  • Milestone set to Awaiting Review

comment:10 jeremyfelt3 months ago

  • Component changed from Multisite to Users
  • Focuses multisite added
Note: See TracTickets for help on using tickets.