]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/queuehandler.php
Merge branch 'master' of /var/www/trunk
[quix0rs-gnu-social.git] / lib / queuehandler.php
index 5e3905f591ce3d8a37ffacb11cdaeb7789e8c7da..9ce9e32b3b718f1d60375607aefbf194cdbcb156 100644 (file)
@@ -25,47 +25,58 @@ require_once(INSTALLDIR.'/lib/daemon.php');
 require_once(INSTALLDIR.'/classes/Queue_item.php');
 require_once(INSTALLDIR.'/classes/Notice.php');
 
-class QueueHandler extends Daemon {
+class QueueHandler extends Daemon
+{
 
     var $_id = 'generic';
 
-    function QueueHandler($id=NULL) {
+    function QueueHandler($id=null)
+    {
         if ($id) {
             $this->set_id($id);
         }
     }
     
-    function class_name() {
+    function class_name()
+    {
         return ucfirst($this->transport()) . 'Handler';
     }
 
-    function name() {
+    function name()
+    {
         return strtolower($this->class_name().'.'.$this->get_id());
     }
     
-    function get_id() {
+    function get_id()
+    {
         return $this->_id;
     }
 
-    function set_id($id) {
+    function set_id($id)
+    {
         $this->_id = $id;
     }
     
-    function transport() {
-        return NULL;
+    function transport()
+    {
+        return null;
     }
     
-    function start() {
+    function start()
+    {
     }
     
-    function finish() {
+    function finish()
+    {
     }
 
-    function handle_notice($notice) {
+    function handle_notice($notice)
+    {
         return true;
     }
     
-    function run() {
+    function run()
+    {
         if (!$this->start()) {
             return false;
         }
@@ -83,7 +94,7 @@ class QueueHandler extends Daemon {
                     if (!$result) {
                         $this->log(LOG_WARNING, 'Failed broadcast for notice ID = ' . $notice->id);
                         $orig = $qi;
-                        $qi->claimed = NULL;
+                        $qi->claimed = null;
                         $qi->update($orig);
                         $this->log(LOG_WARNING, 'Abandoned claim for notice ID = ' . $notice->id);
                         continue;
@@ -91,7 +102,7 @@ class QueueHandler extends Daemon {
                     $this->log(LOG_INFO, 'finished broadcasting notice ID = ' . $notice->id);
                     $notice->free();
                     unset($notice);
-                    $notice = NULL;
+                    $notice = null;
                 } else {
                     $this->log(LOG_WARNING, 'queue item for notice that does not exist');
                 }
@@ -110,13 +121,15 @@ class QueueHandler extends Daemon {
         return true;
     }
 
-    function idle($timeout=0) {
+    function idle($timeout=0)
+    {
         if ($timeout>0) {
             sleep($timeout);
         }
     }
     
-    function clear_old_claims() {
+    function clear_old_claims()
+    {
         $qi = new Queue_item();
         $qi->transport = $this->transport();
         $qi->whereAdd('now() - claimed > '.CLAIM_TIMEOUT);
@@ -125,7 +138,8 @@ class QueueHandler extends Daemon {
         unset($qi);
     }
     
-    function log($level, $msg) {
+    function log($level, $msg)
+    {
         common_log($level, $this->class_name() . ' ('. $this->get_id() .'): '.$msg);
     }
 }