summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruckelman <uckelman@nomic.net>2010-04-27 22:38:16 +0000
committeruckelman <uckelman@nomic.net>2010-04-27 22:38:16 +0000
commit951ac49ab54f2b1cac4e52627f6b906c0a86f6c6 (patch)
treeb4125fc42a57dd6bbf307b15b4584d4b5f158e09 /src
parent313d21ded9bcb30bb6c71434fce1ed93aa042ec4 (diff)
Always get last-edited message id for any post id.
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6774 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src')
-rw-r--r--src/Bridge.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Bridge.php b/src/Bridge.php
index b428fff..91247b8 100644
--- a/src/Bridge.php
+++ b/src/Bridge.php
@@ -26,8 +26,11 @@ class Bridge {
public function getMessageId($postId) {
throw_if_null($postId);
- $sql = 'SELECT message_id FROM posts ' .
- 'WHERE post_id = ' . $postId;
+ $sql = 'SELECT p1.message_id FROM posts AS p1 ' .
+ 'LEFT OUTER JOIN posts AS p2 ON (' .
+ 'p1.post_id = p2.post_id AND ' .
+ 'p1.edit_id < p2.edit_id' .
+ ') WHERE p2.post_id IS NULL';
$row = $this->get_exactly_one_row($sql);
return $row ? $row['message_id'] : false;
@@ -100,6 +103,8 @@ class Bridge {
public function unregisterPost($postId) {
throw_if_null($postId);
+# FIXME: this might need adjusting now that there can be more than one
+# message id per post id.
$sql = 'DELETE FROM posts WHERE post_id = ' . $postId;
$count = $this->db->exec($sql);