From: Michael Vogel Date: Thu, 23 Jul 2015 20:21:22 +0000 (+0200) Subject: Check not only for the last contact but also for the last update for the sanity check. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=880f486044a519e4dd22c7e7f52ebf6e5f50b723;p=friendica.git Check not only for the last contact but also for the last update for the sanity check. --- diff --git a/include/discover_poco.php b/include/discover_poco.php index 74ed83b473..7dbafcafde 100644 --- a/include/discover_poco.php +++ b/include/discover_poco.php @@ -93,11 +93,12 @@ function discover_directory($search) { if(count($j->results)) foreach($j->results as $jj) { // Check if the contact already exists - $exists = q("SELECT `id`, `last_contact`, `last_failure` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url)); + $exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url)); if ($exists) { logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG); - if ($exists[0]["last_contact"] < $exists[0]["last_failure"]) + if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND + ($exists[0]["updated"] < $exists[0]["last_failure"])) continue; // Update the contact diff --git a/mod/dirfind.php b/mod/dirfind.php index 996d2a4641..45fc93b7e8 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -46,7 +46,8 @@ function dirfind_content(&$a) { $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`keywords` FROM `gcontact` LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = %d - WHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND `gcontact`.`last_contact` >= `gcontact`.`last_failure` AND + WHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND + ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND (`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR `gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') GROUP BY `gcontact`.`nurl` diff --git a/mod/poco.php b/mod/poco.php index 250add179f..0b08e30bf0 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -61,7 +61,7 @@ function poco_init(&$a) { $update_limit = date("Y-m-d H:i:s",strtotime($_GET['updatedSince'])); if ($global) { - $r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND ((`last_contact` >= `last_failure`) OR (`updated` > `last_failure`)) AND `network` IN ('%s')", + $r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND `network` IN ('%s')", dbesc($update_limit), dbesc(NETWORK_DFRN) ); @@ -96,7 +96,7 @@ function poco_init(&$a) { if ($global) { - $r = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND `network` IN ('%s') AND `last_contact` >= `last_failure` LIMIT %d, %d", + $r = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND `network` IN ('%s') AND ((`last_contact` >= `last_failure`) OR (`updated` > `last_failure`)) LIMIT %d, %d", dbesc($update_limit), dbesc(NETWORK_DFRN), intval($startIndex), @@ -107,7 +107,7 @@ function poco_init(&$a) { `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`, `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry` FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid` WHERE `self` = 1 AND `network` IN ('%s', '%s', '%s', '%s', '') AND `profile`.`is-default` - AND `contact`.`success_update` >= `contact`.`failure_update` + AND ((`contact`.`success_update` >= `contact`.`failure_update`) OR (`contact`.`last-item` >= `contact`.`failure_update`)) AND `contact`.`uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d", dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA),