summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruckelman <uckelman@nomic.net>2010-07-15 10:34:13 +0000
committeruckelman <uckelman@nomic.net>2010-07-15 10:34:13 +0000
commitb5b7d96db05cca4e1adfdf7869a36a3b4888084d (patch)
tree147fc620889de083189cd5c5c104ffa824d32172 /src
parent1c22d704254cfbee50e0e0456bc1ac066885690f (diff)
* Use isset() instead of array_key_exists (faster).
* There might be several accounts per email address, use the account which was most recently active when looking up user id by email address. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6985 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src')
-rw-r--r--src/PhpBB3.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/PhpBB3.php b/src/PhpBB3.php
index c19df00..7e1b148 100644
--- a/src/PhpBB3.php
+++ b/src/PhpBB3.php
@@ -20,8 +20,15 @@ class PhpBB3 {
global $db;
- $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' ' .
- 'WHERE user_email = "' . $db->sql_escape($from) . '"';
+ # NB: There might be multiple user accounts associated with one email
+ # address. We can only return one user id, so we decide in favor of
+ # the account which was most recently used to visit the forum.
+ $sql = 'SELECT u1.user_id FROM ' . USERS_TABLE . ' AS u1 ' .
+ 'LEFT OUTER JOIN ' . USERS_TABLE . ' AS u2 ON (' .
+ 'u1.user_email = u2.user_email AND ' .
+ 'u1.user_lastvisit < u2.user_lastvisit' .
+ ') WHERE u1.user_email = "' . $db->sql_escape($from) . '" AND ' .
+ 'u2.user_email IS NULL';
$row = $this->get_exactly_one_row($sql);
return $row ? $row['user_id'] : false;
@@ -38,7 +45,7 @@ class PhpBB3 {
throw new Exception("Could not resolve user id $id: $err");
}
- if (!array_key_exists($id, $names)) {
+ if (!isset($names[$id])) {
throw new Exception("Unknown user id: $id");
}