]> git.mxchange.org Git - friendica.git/blobdiff - include/socgraph.php
Merge pull request #3252 from annando/1703-worker-splitting
[friendica.git] / include / socgraph.php
index c55111626fe6d20628e86552851fbb86be01a537..71771bb95d909eb8c9ded6b89c2c5de5b26c5608 100644 (file)
@@ -14,8 +14,13 @@ require_once("include/html2bbcode.php");
 require_once("include/Contact.php");
 require_once("include/Photo.php");
 
-/*
- * poco_load
+/**
+ * @brief Fetch POCO data
+ *
+ * @param integer $cid Contact ID
+ * @param integer $uid User ID
+ * @param integer $zcid Global Contact ID
+ * @param integer $url POCO address that should be polled
  *
  * Given a contact-id (minimum), load the PortableContacts friend list for that contact,
  * and add the entries to the gcontact (Global Contact) table, or update existing entries
@@ -27,12 +32,21 @@ require_once("include/Photo.php");
  * pointing to the same global contact id.
  *
  */
+function poco_load($cid, $uid = 0, $zcid = 0, $url = null) {
+       // Call the function "poco_load_worker" via the worker
+       proc_run(PRIORITY_LOW, "include/discover_poco.php", "poco_load", intval($cid), intval($uid), intval($zcid), base64_encode($url));
+}
 
-
-
-
-function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
-
+/**
+ * @brief Fetch POCO data from the worker
+ *
+ * @param integer $cid Contact ID
+ * @param integer $uid User ID
+ * @param integer $zcid Global Contact ID
+ * @param integer $url POCO address that should be polled
+ *
+ */
+function poco_load_worker($cid, $uid, $zcid, $url) {
        $a = get_app();
 
        if($cid) {
@@ -1739,9 +1753,9 @@ function poco_discover($complete = false) {
 
        $requery_days = intval(get_config("system", "poco_requery_days"));
 
-       if ($requery_days == 0)
+       if ($requery_days == 0) {
                $requery_days = 7;
-
+       }
        $last_update = date("c", time() - (60 * 60 * 24 * $requery_days));
 
        $r = q("SELECT `id`, `url`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update));
@@ -1755,7 +1769,7 @@ function poco_discover($complete = false) {
                        }
 
                        logger('Update directory from server '.$server['url'].' with ID '.$server['id'], LOGGER_DEBUG);
-                       proc_run(PRIORITY_LOW, "include/discover_poco.php", "update_server_directory", $server['id']);
+                       proc_run(PRIORITY_LOW, "include/discover_poco.php", "update_server_directory", intval($server['id']));
 
                        if (!$complete AND (--$no_of_queries == 0)) {
                                break;