Force userId comparisons in SQL to use strings, not numbers.

Use WGBP for reference syntax.
This commit is contained in:
Colin Kuskie 2009-09-05 10:04:16 -07:00
parent 9e2cdbdc4b
commit 2f602dfdb1

View file

@ -185,7 +185,7 @@ sub _visitors {
# that crawlers tend to open multiple sessions(e.g. googlebot) and thereby # that crawlers tend to open multiple sessions(e.g. googlebot) and thereby
# increase the count artificially. Note, that the number determined here # increase the count artificially. Note, that the number determined here
# may deviate from the number of items returned in the visitor loop. # may deviate from the number of items returned in the visitor loop.
$$var{'visitors'} = $db->quickScalar("SELECT COUNT(DISTINCT lastIp) FROM " . $var->{'visitors'} = $db->quickScalar("SELECT COUNT(DISTINCT lastIp) FROM " .
"userSession WHERE (lastPageView > $epoch) AND (userId = 1) AND " . "userSession WHERE (lastPageView > $epoch) AND (userId = 1) AND " .
"lastIp NOT LIKE '127.%.%.%'" . $ip_clause); "lastIp NOT LIKE '127.%.%.%'" . $ip_clause);
@ -198,7 +198,7 @@ sub _visitors {
# Iterate through rows # Iterate through rows
while (my %row = $query->hash) { while (my %row = $query->hash) {
# Add item to visitor template loop # Add item to visitor template loop
push(@{$$var{'visitor_loop'}}, { push(@{$var->{'visitor_loop'}}, {
sessionId => $row{'sessionId'}, sessionId => $row{'sessionId'},
ip => $row{'lastIp'}, ip => $row{'lastIp'},
lastActivity => $dt->epochToHuman($row{'lastPageView'}, $time_format) lastActivity => $dt->epochToHuman($row{'lastPageView'}, $time_format)
@ -249,15 +249,15 @@ sub _members {
# Determine the number of registered users that are online. The Admin # Determine the number of registered users that are online. The Admin
# account is excluded from the list. # account is excluded from the list.
$$var{'members'} = $db->quickScalar("SELECT COUNT(DISTINCT userId) FROM " . $var->{'members'} = $db->quickScalar("SELECT COUNT(DISTINCT userId) FROM " .
"userSession where (lastPageView > $epoch) and (userId != 1) and " . "userSession where (lastPageView > $epoch) and (userId != '1') and " .
"(userId != 3)"); "(userId != '3')");
# Query the names of registered users that are online. The showOnline flag # Query the names of registered users that are online. The showOnline flag
# in the user profile is respected. # in the user profile is respected.
my $query = $db->prepare("SELECT userId, sessionId, lastIp, lastPageView " . my $query = $db->prepare("SELECT userId, sessionId, lastIp, lastPageView " .
"FROM userSession WHERE (lastPageView > $epoch) AND (userId != 1) " . "FROM userSession WHERE (lastPageView > $epoch) AND (userId != '1') " .
"AND (userId != 3) LIMIT $maxMembers"); "AND (userId != '3') LIMIT $maxMembers");
$query->execute; $query->execute;
# Iterate through rows # Iterate through rows
@ -279,7 +279,7 @@ sub _members {
} }
# Add item to member template loop # Add item to member template loop
push(@{$$var{'member_loop'}}, { push(@{$var->{'member_loop'}}, {
username => $user->username(), username => $user->username(),
firstName => $user->profileField("firstName"), firstName => $user->profileField("firstName"),
middleName => $user->profileField("middleName"), middleName => $user->profileField("middleName"),