Commit 79bf6016 authored by mig5's avatar mig5 Committed by Steven Jones

Issue #1503824 by mig5: Fixed hosting_site_count() ignores disabled sites.

parent 567443f6
......@@ -509,7 +509,7 @@ function hosting_platform_listing() {
$row[] = _hosting_node_link($node->release->nid, $release);
$row[] = _hosting_node_link($node->web_server);
$row[] = hosting_format_interval($node->verified);
$total += $count = hosting_site_count($nid);
$total += $count = hosting_site_count($nid, array(HOSTING_SITE_ENABLED, HOSTING_SITE_DISABLED, HOSTING_SITE_QUEUED));
$row[] = $count;
$rows[] = array('data' => $row, 'class' => _hosting_platform_list_class($node));
}
......
......@@ -283,17 +283,47 @@ function hosting_site_access($op, $node, $account) {
}
/**
* Return a count of enabled sites.
* Returns a count of sites.
*
* This is used by cron and statistics to batch the number of sites that are processed with each call
*
* It is also used to generate the 'site count' per platform at /hosting/platforms
*
* By default it only counts enabled sites.
*
* Optionally can include an array of site statuses by which to consider in the count.
*
* @param $platform
* (optional) A platform nid to only count sites on that specific platform.
*
* @param $statuses
* (optional) An array of site statuses (defined by their constants) by which to include
* such sites in the site count.
*
* @return
* The result of the database query
*/
function hosting_site_count($platform = null) {
$query = "SELECT count(nid) FROM {hosting_site} WHERE status = %d";
$args = array(HOSTING_SITE_ENABLED);
function hosting_site_count($platform = null, $statuses = NULL) {
$args = array();
$query = "SELECT count(nid) FROM {hosting_site} WHERE";
if (is_null($statuses)) {
$query .= " status = %d";
$args[] = HOSTING_SITE_ENABLED;
}
else {
if (count($statuses)) {
$query .= ' (status IN (' . db_placeholders($statuses) . '))';
$args = array_merge($args, $statuses);
}
}
if (!is_null($platform)) {
$query .= " AND platform = %d";
$args[] = $platform;
}
return db_result(db_query($query, $args));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment