1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Minor, fix insertNotifications() for unmigrated callsites. See discussion in rP3a6ee79190b709d84ff79865d1c1d6234e5c102a.

This commit is contained in:
epriestley 2012-06-08 19:15:42 -07:00
parent 284d7b6a46
commit 4d6df7dc14

View file

@ -104,35 +104,39 @@ final class PhabricatorFeedStoryPublisher {
private function insertNotifications($chrono_key) { private function insertNotifications($chrono_key) {
if (!$this->subscribedPHIDs) {
return;
}
if (!$this->primaryObjectPHID) { if (!$this->primaryObjectPHID) {
throw throw new Exception(
new Exception("Call setPrimaryObjectPHID() before Publishing!"); "You must call setPrimaryObjectPHID() if you setSubscribedPHIDs()!");
} }
if ($this->subscribedPHIDs) {
$notif = new PhabricatorFeedStoryNotification();
$sql = array();
$conn = $notif->establishConnection('w');
foreach (array_unique($this->subscribedPHIDs) as $user_phid) { $notif = new PhabricatorFeedStoryNotification();
$sql[] = qsprintf( $sql = array();
$conn, $conn = $notif->establishConnection('w');
'(%s, %s, %s, %d)',
$this->primaryObjectPHID,
$user_phid,
$chrono_key,
0);
}
queryfx( foreach (array_unique($this->subscribedPHIDs) as $user_phid) {
$sql[] = qsprintf(
$conn, $conn,
'INSERT INTO %T '(%s, %s, %s, %d)',
(primaryObjectPHID, userPHID, chronologicalKey, hasViewed) $this->primaryObjectPHID,
VALUES %Q', $user_phid,
$notif->getTableName(), $chrono_key,
implode(', ', $sql)); 0);
} }
queryfx(
$conn,
'INSERT INTO %T
(primaryObjectPHID, userPHID, chronologicalKey, hasViewed)
VALUES %Q',
$notif->getTableName(),
implode(', ', $sql));
} }
/** /**
* We generate a unique chronological key for each story type because we want * We generate a unique chronological key for each story type because we want
* to be able to page through the stream with a cursor (i.e., select stories * to be able to page through the stream with a cursor (i.e., select stories