summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-11 09:55:47 -0500
committerEvan Prodromou <evan@status.net>2009-12-11 09:55:47 -0500
commite9b733e7f036bc03353ae6dd7b096ea179698a4d (patch)
tree1f93b0344e3d5b7c1e50f9ee272c8dc8d8ecf8c6 /classes
parent78fc9483d4d1fde4561905edf6594b86c4dc374e (diff)
parent85473ecf94e92cd0e6503e4d27ea26452076aafd (diff)
Merge branch '0.9.x' into testing
Diffstat (limited to 'classes')
-rw-r--r--classes/Login_token.php13
-rw-r--r--classes/Notice.php52
-rw-r--r--classes/Notice_inbox.php42
-rw-r--r--classes/statusnet.ini1
4 files changed, 71 insertions, 37 deletions
diff --git a/classes/Login_token.php b/classes/Login_token.php
index c172b30ab..746cd7f22 100644
--- a/classes/Login_token.php
+++ b/classes/Login_token.php
@@ -39,4 +39,17 @@ class Login_token extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+
+ /*
+ DB_DataObject calculates the sequence key(s) by taking the first key returned by the keys() function.
+ In this case, the keys() function returns user_id as the first key. user_id is not a sequence, but
+ DB_DataObject's sequenceKey() will incorrectly think it is. Then, since the sequenceKey() is a numeric
+ type, but is not set to autoincrement in the database, DB_DataObject will create a _seq table and
+ manage the sequence itself. This is not the correct behavior for the user_id in this class.
+ So we override that incorrect behavior, and simply say there is no sequence key.
+ */
+ function sequenceKey()
+ {
+ return array(false,false);
+ }
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 661072156..c36c5a9c6 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -788,10 +788,24 @@ class Notice extends Memcached_DataObject
return $notice;
}
$notice->whereAdd('id in (' . implode(', ', $ids) . ')');
- $notice->orderBy('id DESC');
$notice->find();
- return $notice;
+
+ $temp = array();
+
+ while ($notice->fetch()) {
+ $temp[$notice->id] = clone($notice);
+ }
+
+ $wrapped = array();
+
+ foreach ($ids as $id) {
+ if (array_key_exists($id, $temp)) {
+ $wrapped[] = $temp[$id];
+ }
+ }
+
+ return new ArrayWrapper($wrapped);
}
}
@@ -948,39 +962,7 @@ class Notice extends Memcached_DataObject
}
}
- $cnt = 0;
-
- $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
- $qry = $qryhdr;
-
- foreach ($ni as $id => $source) {
- if ($cnt > 0) {
- $qry .= ', ';
- }
- $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') ";
- $cnt++;
- if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
- // FIXME: Causes lag in replicated servers
- // Notice_inbox::gc($id);
- }
- if ($cnt >= MAX_BOXCARS) {
- $inbox = new Notice_inbox();
- $result = $inbox->query($qry);
- if (PEAR::isError($result)) {
- common_log_db_error($inbox, $qry);
- }
- $qry = $qryhdr;
- $cnt = 0;
- }
- }
-
- if ($cnt > 0) {
- $inbox = new Notice_inbox();
- $result = $inbox->query($qry);
- if (PEAR::isError($result)) {
- common_log_db_error($inbox, $qry);
- }
- }
+ Notice_inbox::bulkInsert($this->id, $this->created, $ni);
return;
}
diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php
index d3e7853b1..b39006542 100644
--- a/classes/Notice_inbox.php
+++ b/classes/Notice_inbox.php
@@ -32,6 +32,7 @@ define('NOTICE_INBOX_SOFT_LIMIT', 1000);
define('NOTICE_INBOX_SOURCE_SUB', 1);
define('NOTICE_INBOX_SOURCE_GROUP', 2);
define('NOTICE_INBOX_SOURCE_REPLY', 3);
+define('NOTICE_INBOX_SOURCE_FORWARD', 4);
define('NOTICE_INBOX_SOURCE_GATEWAY', -1);
class Notice_inbox extends Memcached_DataObject
@@ -83,7 +84,7 @@ class Notice_inbox extends Memcached_DataObject
$inbox->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
}
- $inbox->orderBy('notice_id DESC');
+ $inbox->orderBy('created DESC');
if (!is_null($offset)) {
$inbox->limit($offset, $limit);
@@ -141,4 +142,43 @@ class Notice_inbox extends Memcached_DataObject
'WHERE user_id = ' . $user_id . ' ' .
'AND notice_id in ('.implode(',', $notices).')');
}
+
+ static function bulkInsert($notice_id, $created, $ni)
+ {
+ $cnt = 0;
+
+ $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
+ $qry = $qryhdr;
+
+ foreach ($ni as $id => $source) {
+ if ($cnt > 0) {
+ $qry .= ', ';
+ }
+ $qry .= '('.$id.', '.$notice_id.', '.$source.", '".$created. "') ";
+ $cnt++;
+ if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
+ // FIXME: Causes lag in replicated servers
+ // Notice_inbox::gc($id);
+ }
+ if ($cnt >= MAX_BOXCARS) {
+ $inbox = new Notice_inbox();
+ $result = $inbox->query($qry);
+ if (PEAR::isError($result)) {
+ common_log_db_error($inbox, $qry);
+ }
+ $qry = $qryhdr;
+ $cnt = 0;
+ }
+ }
+
+ if ($cnt > 0) {
+ $inbox = new Notice_inbox();
+ $result = $inbox->query($qry);
+ if (PEAR::isError($result)) {
+ common_log_db_error($inbox, $qry);
+ }
+ }
+
+ return;
+ }
}
diff --git a/classes/statusnet.ini b/classes/statusnet.ini
index 5c942c63a..f12707ba1 100644
--- a/classes/statusnet.ini
+++ b/classes/statusnet.ini
@@ -260,7 +260,6 @@ modified = 384
[login_token__keys]
user_id = K
-token = K
[message]
id = 129