if (isset($user->email)) {
- $result = mail_twitter_bridge_removed($user);
+ $result = mail_twitter_bridge_removed($user);
+
+ if (!$result) {
+
+ $msg = 'Unable to send email to notify ' .
+ "$user->nickname (user id: $user->id) " .
+ 'that their Twitter bridge link was ' .
+ 'removed!';
+
+ common_log(LOG_WARNING, $msg);
+ }
+ }
+
++}
++
++ $result = mail_twitter_bridge_removed($user);
++
++ if (!$result) {
++
++ $msg = 'Unable to send email to notify ' .
++ "$user->nickname (user id: $user->id) " .
++ 'that their Twitter bridge link was ' .
++ 'removed!';
++
++ common_log(LOG_WARNING, $msg);
++ }
++ }
++
++}
++
++ $result = mail_twitter_bridge_removed($user);
+
- if (!$result) {
++ if (!$result) {
+
- $msg = 'Unable to send email to notify ' .
- "$user->nickname (user id: $user->id) " .
- 'that their Twitter bridge link was ' .
- 'removed!';
++ $msg = 'Unable to send email to notify ' .
++ "$user->nickname (user id: $user->id) " .
++ 'that their Twitter bridge link was ' .
++ 'removed!';
+
- common_log(LOG_WARNING, $msg);
++ common_log(LOG_WARNING, $msg);
++ }
+ }
++
++}
++
++ $result = mail_twitter_bridge_removed($user);
++
++ if (!$result) {
++
++ $msg = 'Unable to send email to notify ' .
++ "$user->nickname (user id: $user->id) " .
++ 'that their Twitter bridge link was ' .
++ 'removed!';
++
++ common_log(LOG_WARNING, $msg);
++ }
++ }
++
++}
++
++ $result = mail_twitter_bridge_removed($user);
++
++ if (!$result) {
++
++ $msg = 'Unable to send email to notify ' .
++ "$user->nickname (user id: $user->id) " .
++ 'that their Twitter bridge link was ' .
++ 'removed!';
++
++ common_log(LOG_WARNING, $msg);
++ }
+ }
+
}
}
/**
- * Run the daemon
+ * Find all the Twitter foreign links for users who have requested
+ * importing of their friends' timelines
*
- * @return void
+ * @return array flinks an array of Foreign_link objects
*/
- function run()
+ function getObjects()
{
- if (defined('SCRIPT_DEBUG')) {
- common_debug($this->name() .
- ': debugging log output enabled.');
- }
-
- do {
-
- $flinks = $this->refreshFlinks();
-
- foreach ($flinks as $f) {
-
- $pid = pcntl_fork();
-
- if ($pid == -1) {
- die ("Couldn't fork!");
- }
-
- if ($pid) {
-
- // Parent
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Parent: forked new status ".
- " fetcher process " . $pid);
- }
-
- $this->_children[] = $pid;
-
- } else {
-
- // Child
-
- // Each child ps needs its own DB connection
-
- // Note: DataObject::getDatabaseConnection() creates
- // a new connection if there isn't one already
-
- global $_DB_DATAOBJECT;
- $conn = &$f->getDatabaseConnection();
-
- $this->getTimeline($f);
-
- $conn->disconnect();
-
- // XXX: Couldn't find a less brutal way to blow
- // away a cached connection
-
- unset($_DB_DATAOBJECT['CONNECTIONS']);
-
- exit();
- }
-
- // Remove child from ps list as it finishes
- while (($c = pcntl_wait($status, WNOHANG OR WUNTRACED)) > 0) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Child $c finished.");
- }
-
- $this->removePs($this->_children, $c);
- }
-
- // Wait! We have too many damn kids.
- if (sizeof($this->_children) > MAXCHILDREN) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Too many children. Waiting...');
- }
-
- if (($c = pcntl_wait($status, WUNTRACED)) > 0) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Finished waiting for $c");
- }
-
- $this->removePs($this->_children, $c);
- }
- }
- }
-
- // Remove all children from the process list before restarting
- while (($c = pcntl_wait($status, WUNTRACED)) > 0) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Child $c finished.");
- }
-
- $this->removePs($this->_children, $c);
- }
-
- // Rest for a bit before we fetch more statuses
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Waiting ' . POLL_INTERVAL .
- ' secs before hitting Twitter again.');
- }
-
- if (POLL_INTERVAL > 0) {
- sleep(POLL_INTERVAL);
- }
-
- } while (true);
- }
-
- /**
- * Refresh the foreign links for this user
- *
- * @return void
- */
+ global $_DB_DATAOBJECT;
- function refreshFlinks()
- {
++=======
+ global $_DB_DATAOBJECT;
+
++>>>>>>> 0.8.x:scripts/twitterstatusfetcher.php
$flink = new Foreign_link();
$conn = &$flink->getDatabaseConnection();