Improve dba::selectFirst calls
- Fix remaining $r[0] references - Rename $r to meaningful names
This commit is contained in:
parent
465e1d6a5c
commit
5fc4927764
29 changed files with 228 additions and 250 deletions
|
@ -58,9 +58,9 @@ class OEmbed
|
|||
$a = get_app();
|
||||
|
||||
$condition = ['url' => normalise_link($embedurl), 'maxwidth' => $a->videowidth];
|
||||
$r = dba::selectFirst('oembed', ['content'], $condition);
|
||||
if (DBM::is_result($r)) {
|
||||
$txt = $r["content"];
|
||||
$oembed = dba::selectFirst('oembed', ['content'], $condition);
|
||||
if (DBM::is_result($oembed)) {
|
||||
$txt = $oembed["content"];
|
||||
} else {
|
||||
$txt = Cache::get($a->videowidth . $embedurl);
|
||||
}
|
||||
|
|
|
@ -109,10 +109,10 @@ class Cache
|
|||
// Frequently clear cache
|
||||
self::clear();
|
||||
|
||||
$r = dba::selectFirst('cache', ['v'], ['k' => $key]);
|
||||
$cache = dba::selectFirst('cache', ['v'], ['k' => $key]);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$cached = $r['v'];
|
||||
if (DBM::is_result($cache)) {
|
||||
$cached = $cache['v'];
|
||||
$value = @unserialize($cached);
|
||||
|
||||
// Only return a value if the serialized value is valid.
|
||||
|
|
|
@ -97,10 +97,10 @@ class Config
|
|||
}
|
||||
}
|
||||
|
||||
$ret = dba::selectFirst('config', ['v'], ['cat' => $family, 'k' => $key]);
|
||||
if (DBM::is_result($ret)) {
|
||||
$config = dba::selectFirst('config', ['v'], ['cat' => $family, 'k' => $key]);
|
||||
if (DBM::is_result($config)) {
|
||||
// manage array value
|
||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
|
||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
|
||||
|
||||
// Assign the value from the database to the cache
|
||||
self::$cache[$family][$key] = $val;
|
||||
|
|
|
@ -90,9 +90,9 @@ class PConfig
|
|||
}
|
||||
}
|
||||
|
||||
$ret = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $family, 'k' => $key]);
|
||||
if (DBM::is_result($ret)) {
|
||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
|
||||
$pconfig = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $family, 'k' => $key]);
|
||||
if (DBM::is_result($pconfig)) {
|
||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $pconfig['v']) ? unserialize($pconfig['v']) : $pconfig['v']);
|
||||
$a->config[$uid][$family][$key] = $val;
|
||||
self::$in_db[$uid][$family][$key] = true;
|
||||
|
||||
|
|
|
@ -165,9 +165,9 @@ class Worker
|
|||
private static function highestPriority()
|
||||
{
|
||||
$condition = array("`executed` <= ? AND NOT `done`", NULL_DATE);
|
||||
$s = dba::selectFirst('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
|
||||
if (DBM::is_result($s)) {
|
||||
return $s["priority"];
|
||||
$workerqueue = dba::selectFirst('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
|
||||
if (DBM::is_result($workerqueue)) {
|
||||
return $workerqueue["priority"];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -145,13 +145,12 @@ class Contact extends BaseObject
|
|||
public static function remove($id)
|
||||
{
|
||||
// We want just to make sure that we don't delete our "self" contact
|
||||
$r = dba::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
|
||||
|
||||
if (!DBM::is_result($r) || !intval($r['uid'])) {
|
||||
$contact = dba::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
|
||||
if (!DBM::is_result($contact) || !intval($contact['uid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$archive = PConfig::get($r['uid'], 'system', 'archive_removed_contacts');
|
||||
$archive = PConfig::get($contact['uid'], 'system', 'archive_removed_contacts');
|
||||
if ($archive) {
|
||||
dba::update('contact', array('archive' => true, 'network' => 'none', 'writable' => false), array('id' => $id));
|
||||
return;
|
||||
|
@ -490,9 +489,10 @@ class Contact extends BaseObject
|
|||
return $menu;
|
||||
}
|
||||
|
||||
$r = dba::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
|
||||
if ($r) {
|
||||
return self::photoMenu($r, $uid);
|
||||
// Look for our own contact if the uid doesn't match and isn't public
|
||||
$contact_own = dba::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
|
||||
if (DBM::is_result($contact_own)) {
|
||||
return self::photoMenu($contact_own, $uid);
|
||||
} else {
|
||||
$profile_link = zrl($contact['url']);
|
||||
$connlnk = 'follow/?url=' . $contact['url'];
|
||||
|
@ -664,9 +664,8 @@ class Contact extends BaseObject
|
|||
if (!DBM::is_result($contact)) {
|
||||
// The link could be provided as http although we stored it as https
|
||||
$ssl_url = str_replace('http://', 'https://', $url);
|
||||
$r = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid]);
|
||||
$contact = dba::fetch($r);
|
||||
dba::close($r);
|
||||
$condition = ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid];
|
||||
$contact = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], $condition);
|
||||
}
|
||||
|
||||
if (DBM::is_result($contact)) {
|
||||
|
@ -697,12 +696,12 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
// Get data from the gcontact table
|
||||
$gcontacts = dba::selectFirst('gcontact', ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'], ['nurl' => normalise_link($url)]);
|
||||
if (!DBM::is_result($gcontacts)) {
|
||||
$gcontact = dba::selectFirst('gcontact', ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'], ['nurl' => normalise_link($url)]);
|
||||
if (!DBM::is_result($gcontact)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$data = array_merge($data, $gcontacts);
|
||||
$data = array_merge($data, $gcontact);
|
||||
}
|
||||
|
||||
if (!$contact_id && ($data["alias"] != '') && ($data["alias"] != $url)) {
|
||||
|
@ -726,7 +725,7 @@ class Contact extends BaseObject
|
|||
'readonly' => 0, 'pending' => 0)
|
||||
);
|
||||
|
||||
$s = dba::select('contact', array('id'), array('nurl' => normalise_link($data["url"]), 'uid' => $uid), array('order' => array('id'), 'limit' => 2));
|
||||
$s = dba::select('contact', ['id'], ['nurl' => normalise_link($data["url"]), 'uid' => $uid], ['order' => ['id'], 'limit' => 2]);
|
||||
$contacts = dba::inArray($s);
|
||||
if (!DBM::is_result($contacts)) {
|
||||
return 0;
|
||||
|
@ -979,15 +978,14 @@ class Contact extends BaseObject
|
|||
*/
|
||||
public static function updateAvatar($avatar, $uid, $cid, $force = false)
|
||||
{
|
||||
// Limit = 1 returns the row so no need for dba:inArray()
|
||||
$r = dba::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
|
||||
if (!DBM::is_result($r)) {
|
||||
$contact = dba::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
return false;
|
||||
} else {
|
||||
$data = array($r["photo"], $r["thumb"], $r["micro"]);
|
||||
$data = array($contact["photo"], $contact["thumb"], $contact["micro"]);
|
||||
}
|
||||
|
||||
if (($r["avatar"] != $avatar) || $force) {
|
||||
if (($contact["avatar"] != $avatar) || $force) {
|
||||
$photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
|
||||
|
||||
if ($photos) {
|
||||
|
@ -999,7 +997,7 @@ class Contact extends BaseObject
|
|||
|
||||
// Update the public contact (contact id = 0)
|
||||
if ($uid != 0) {
|
||||
$pcontact = dba::selectFirst('contact', ['id'], ['nurl' => $r[0]['nurl']]);
|
||||
$pcontact = dba::selectFirst('contact', ['id'], ['nurl' => $contact['nurl']]);
|
||||
if (DBM::is_result($pcontact)) {
|
||||
self::updateAvatar($avatar, 0, $pcontact['id'], $force);
|
||||
}
|
||||
|
@ -1023,15 +1021,16 @@ class Contact extends BaseObject
|
|||
This will reliably kill your communication with Friendica contacts.
|
||||
*/
|
||||
|
||||
$r = dba::selectFirst('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id]);
|
||||
if (!DBM::is_result($r)) {
|
||||
$fields = ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'];
|
||||
$contact = dba::selectFirst('contact', $fields, ['id' => $id]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = Probe::uri($r["url"]);
|
||||
$ret = Probe::uri($contact["url"]);
|
||||
|
||||
// If Probe::uri fails the network code will be different
|
||||
if ($ret["network"] != $r["network"]) {
|
||||
if ($ret["network"] != $contact["network"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1039,11 +1038,13 @@ class Contact extends BaseObject
|
|||
|
||||
// make sure to not overwrite existing values with blank entries
|
||||
foreach ($ret as $key => $val) {
|
||||
if (isset($r[$key]) && ($r[$key] != "") && ($val == ""))
|
||||
$ret[$key] = $r[$key];
|
||||
if (isset($contact[$key]) && ($contact[$key] != "") && ($val == "")) {
|
||||
$ret[$key] = $contact[$key];
|
||||
}
|
||||
|
||||
if (isset($r[$key]) && ($ret[$key] != $r[$key]))
|
||||
if (isset($contact[$key]) && ($ret[$key] != $contact[$key])) {
|
||||
$update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$update) {
|
||||
|
|
|
@ -766,7 +766,7 @@ class GContact
|
|||
return false;
|
||||
}
|
||||
|
||||
$r = q(
|
||||
$public_contact = q(
|
||||
"SELECT `name`, `nick`, `photo`, `location`, `about`, `addr`, `generation`, `birthday`, `gender`, `keywords`,
|
||||
`contact-type`, `hide`, `nsfw`, `network`, `alias`, `notify`, `server_url`, `connect`, `updated`, `url`
|
||||
FROM `gcontact` WHERE `id` = %d LIMIT 1",
|
||||
|
@ -775,7 +775,7 @@ class GContact
|
|||
|
||||
// Get all field names
|
||||
$fields = array();
|
||||
foreach ($r[0] as $field => $data) {
|
||||
foreach ($public_contact[0] as $field => $data) {
|
||||
$fields[$field] = $data;
|
||||
}
|
||||
|
||||
|
@ -789,22 +789,22 @@ class GContact
|
|||
unset($contact["keywords"]);
|
||||
}
|
||||
|
||||
if ($r[0]["keywords"] == "0") {
|
||||
$r[0]["keywords"] = "";
|
||||
if ($public_contact[0]["keywords"] == "0") {
|
||||
$public_contact[0]["keywords"] = "";
|
||||
}
|
||||
|
||||
// assign all unassigned fields from the database entry
|
||||
foreach ($fields as $field => $data) {
|
||||
if (!isset($contact[$field]) || ($contact[$field] == "")) {
|
||||
$contact[$field] = $r[0][$field];
|
||||
$contact[$field] = $public_contact[0][$field];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($contact["hide"])) {
|
||||
$contact["hide"] = $r[0]["hide"];
|
||||
$contact["hide"] = $public_contact[0]["hide"];
|
||||
}
|
||||
|
||||
$fields["hide"] = $r[0]["hide"];
|
||||
$fields["hide"] = $public_contact[0]["hide"];
|
||||
|
||||
if ($contact["network"] == NETWORK_STATUSNET) {
|
||||
$contact["network"] = NETWORK_OSTATUS;
|
||||
|
@ -839,16 +839,16 @@ class GContact
|
|||
$update = false;
|
||||
unset($fields["generation"]);
|
||||
|
||||
if ((($contact["generation"] > 0) && ($contact["generation"] <= $r[0]["generation"])) || ($r[0]["generation"] == 0)) {
|
||||
if ((($contact["generation"] > 0) && ($contact["generation"] <= $public_contact[0]["generation"])) || ($public_contact[0]["generation"] == 0)) {
|
||||
foreach ($fields as $field => $data) {
|
||||
if ($contact[$field] != $r[0][$field]) {
|
||||
logger("Difference for contact ".$contact["url"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$r[0][$field]."'", LOGGER_DEBUG);
|
||||
if ($contact[$field] != $public_contact[0][$field]) {
|
||||
logger("Difference for contact ".$contact["url"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$public_contact[0][$field]."'", LOGGER_DEBUG);
|
||||
$update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($contact["generation"] < $r[0]["generation"]) {
|
||||
logger("Difference for contact ".$contact["url"]." in field 'generation'. new value: '".$contact["generation"]."', old value '".$r[0]["generation"]."'", LOGGER_DEBUG);
|
||||
if ($contact["generation"] < $public_contact[0]["generation"]) {
|
||||
logger("Difference for contact ".$contact["url"]." in field 'generation'. new value: '".$contact["generation"]."', old value '".$public_contact[0]["generation"]."'", LOGGER_DEBUG);
|
||||
$update = true;
|
||||
}
|
||||
}
|
||||
|
@ -874,21 +874,18 @@ class GContact
|
|||
|
||||
// Now update the contact entry with the user id "0" as well.
|
||||
// This is used for the shadow copies of public items.
|
||||
$r = q(
|
||||
"SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0 ORDER BY `id` LIMIT 1",
|
||||
dbesc(normalise_link($contact["url"]))
|
||||
);
|
||||
|
||||
$public_contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
|
||||
if (DBM::is_result($public_contact)) {
|
||||
logger("Update public contact ".$public_contact["id"], LOGGER_DEBUG);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
logger("Update public contact ".$r[0]["id"], LOGGER_DEBUG);
|
||||
|
||||
Contact::updateAvatar($contact["photo"], 0, $r[0]["id"]);
|
||||
Contact::updateAvatar($contact["photo"], 0, $public_contact["id"]);
|
||||
|
||||
$fields = array('name', 'nick', 'addr',
|
||||
'network', 'bd', 'gender',
|
||||
'keywords', 'alias', 'contact-type',
|
||||
'url', 'location', 'about');
|
||||
$old_contact = dba::selectFirst('contact', $fields, ['id' => $r[0]["id"]]);
|
||||
$old_contact = dba::selectFirst('contact', $fields, ['id' => $public_contact["id"]]);
|
||||
|
||||
// Update it with the current values
|
||||
$fields = array('name' => $contact['name'], 'nick' => $contact['nick'],
|
||||
|
@ -898,7 +895,7 @@ class GContact
|
|||
'contact-type' => $contact['contact-type'], 'url' => $contact['url'],
|
||||
'location' => $contact['location'], 'about' => $contact['about']);
|
||||
|
||||
dba::update('contact', $fields, array('id' => $r[0]["id"]), $old_contact);
|
||||
dba::update('contact', $fields, array('id' => $public_contact["id"]), $old_contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,16 +38,16 @@ class Photo
|
|||
*/
|
||||
public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '')
|
||||
{
|
||||
$r = dba::selectFirst('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
|
||||
if (DBM::is_result($r)) {
|
||||
$guid = $r['guid'];
|
||||
$photo = dba::selectFirst('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
|
||||
if (DBM::is_result($photo)) {
|
||||
$guid = $photo['guid'];
|
||||
} else {
|
||||
$guid = get_guid();
|
||||
}
|
||||
|
||||
$x = dba::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
|
||||
$existing_photo = dba::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
|
||||
|
||||
$fields = array(
|
||||
$fields = [
|
||||
'uid' => $uid,
|
||||
'contact-id' => $cid,
|
||||
'guid' => $guid,
|
||||
|
@ -68,10 +68,10 @@ class Photo
|
|||
'deny_cid' => $deny_cid,
|
||||
'deny_gid' => $deny_gid,
|
||||
'desc' => $desc
|
||||
);
|
||||
];
|
||||
|
||||
if (DBM::is_result($x)) {
|
||||
$r = dba::update('photo', $fields, array('id' => $x['id']));
|
||||
if (DBM::is_result($existing_photo)) {
|
||||
$r = dba::update('photo', $fields, ['id' => $existing_photo['id']]);
|
||||
} else {
|
||||
$r = dba::insert('photo', $fields);
|
||||
}
|
||||
|
@ -80,34 +80,33 @@ class Photo
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $photo photo
|
||||
* @param string $image_url Remote URL
|
||||
* @param integer $uid user id
|
||||
* @param integer $cid contact id
|
||||
* @param boolean $quit_on_error optional, default false
|
||||
* @return array
|
||||
*/
|
||||
public static function importProfilePhoto($photo, $uid, $cid, $quit_on_error = false)
|
||||
public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false)
|
||||
{
|
||||
$r = dba::selectFirst(
|
||||
$photo = dba::selectFirst(
|
||||
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
|
||||
);
|
||||
|
||||
if (DBM::is_result($r) && strlen($r['resource-id'])) {
|
||||
$hash = $r['resource-id'];
|
||||
if (x($photo['resource-id'])) {
|
||||
$hash = $photo['resource-id'];
|
||||
} else {
|
||||
$hash = photo_new_resource();
|
||||
}
|
||||
|
||||
$photo_failure = false;
|
||||
|
||||
$filename = basename($photo);
|
||||
$img_str = fetch_url($photo, true);
|
||||
$filename = basename($image_url);
|
||||
$img_str = fetch_url($image_url, true);
|
||||
|
||||
if ($quit_on_error && ($img_str == "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = Image::guessType($photo, true);
|
||||
$type = Image::guessType($image_url, true);
|
||||
$Image = new Image($img_str, $type);
|
||||
if ($Image->isValid()) {
|
||||
$Image->scaleToSquare(175);
|
||||
|
@ -136,7 +135,7 @@ class Photo
|
|||
|
||||
$suffix = '?ts=' . time();
|
||||
|
||||
$photo = System::baseUrl() . '/photo/' . $hash . '-4.' . $Image->getExt() . $suffix;
|
||||
$image_url = System::baseUrl() . '/photo/' . $hash . '-4.' . $Image->getExt() . $suffix;
|
||||
$thumb = System::baseUrl() . '/photo/' . $hash . '-5.' . $Image->getExt() . $suffix;
|
||||
$micro = System::baseUrl() . '/photo/' . $hash . '-6.' . $Image->getExt() . $suffix;
|
||||
|
||||
|
@ -167,12 +166,12 @@ class Photo
|
|||
}
|
||||
|
||||
if ($photo_failure) {
|
||||
$photo = System::baseUrl() . '/images/person-175.jpg';
|
||||
$image_url = System::baseUrl() . '/images/person-175.jpg';
|
||||
$thumb = System::baseUrl() . '/images/person-80.jpg';
|
||||
$micro = System::baseUrl() . '/images/person-48.jpg';
|
||||
}
|
||||
|
||||
return array($photo, $thumb, $micro);
|
||||
return array($image_url, $thumb, $micro);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,11 +63,10 @@ class FKOAuth1 extends OAuthServer
|
|||
$a->timezone = $a->user['timezone'];
|
||||
}
|
||||
|
||||
$r = dba::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => 1]);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$a->contact = $r;
|
||||
$a->cid = $r['id'];
|
||||
$contact = dba::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => 1]);
|
||||
if (DBM::is_result($contact)) {
|
||||
$a->contact = $contact;
|
||||
$a->cid = $contact['id'];
|
||||
$_SESSION['cid'] = $a->cid;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,10 +88,9 @@ class FKOAuthDataStore extends OAuthDataStore
|
|||
*/
|
||||
public function lookup_nonce($consumer, $token, $nonce, $timestamp)
|
||||
{
|
||||
$r = dba::selectFirst('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp]);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
return new \OAuthToken($r['id'], $r['secret']);
|
||||
$token = dba::selectFirst('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp]);
|
||||
if (DBM::is_result($token)) {
|
||||
return new \OAuthToken($token['id'], $token['secret']);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -261,14 +261,14 @@ class Post extends BaseObject
|
|||
'classundo' => $item['starred'] ? "" : "hidden",
|
||||
'starred' => t('starred'),
|
||||
);
|
||||
$r = dba::selectFirst('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
|
||||
if (DBM::is_result($r)) {
|
||||
$thread = dba::selectFirst('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
|
||||
if (DBM::is_result($thread)) {
|
||||
$ignore = array(
|
||||
'do' => t("ignore thread"),
|
||||
'undo' => t("unignore thread"),
|
||||
'toggle' => t("toggle ignore status"),
|
||||
'classdo' => $r['ignored'] ? "hidden" : "",
|
||||
'classundo' => $r['ignored'] ? "" : "hidden",
|
||||
'classdo' => $thread['ignored'] ? "hidden" : "",
|
||||
'classundo' => $thread['ignored'] ? "" : "hidden",
|
||||
'ignored' => t('ignored'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -66,10 +66,10 @@ class PortableContact
|
|||
|
||||
if ($cid) {
|
||||
if (!$url || !$uid) {
|
||||
$r = dba::selectFirst('contact', ['poco', 'uid'], ['id' => $cid]);
|
||||
if (DBM::is_result($r)) {
|
||||
$url = $r['poco'];
|
||||
$uid = $r['uid'];
|
||||
$contact = dba::selectFirst('contact', ['poco', 'uid'], ['id' => $cid]);
|
||||
if (DBM::is_result($contact)) {
|
||||
$url = $contact['poco'];
|
||||
$uid = $contact['uid'];
|
||||
}
|
||||
}
|
||||
if (!$uid) {
|
||||
|
@ -813,30 +813,30 @@ class PortableContact
|
|||
return false;
|
||||
}
|
||||
|
||||
$servers = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
|
||||
if (DBM::is_result($servers)) {
|
||||
if ($servers["created"] <= NULL_DATE) {
|
||||
$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
|
||||
if (DBM::is_result($gserver)) {
|
||||
if ($gserver["created"] <= NULL_DATE) {
|
||||
$fields = ['created' => datetime_convert()];
|
||||
$condition = ['nurl' => normalise_link($server_url)];
|
||||
dba::update('gserver', $fields, $condition);
|
||||
}
|
||||
$poco = $servers["poco"];
|
||||
$noscrape = $servers["noscrape"];
|
||||
$poco = $gserver["poco"];
|
||||
$noscrape = $gserver["noscrape"];
|
||||
|
||||
if ($network == "") {
|
||||
$network = $servers["network"];
|
||||
$network = $gserver["network"];
|
||||
}
|
||||
|
||||
$last_contact = $servers["last_contact"];
|
||||
$last_failure = $servers["last_failure"];
|
||||
$version = $servers["version"];
|
||||
$platform = $servers["platform"];
|
||||
$site_name = $servers["site_name"];
|
||||
$info = $servers["info"];
|
||||
$register_policy = $servers["register_policy"];
|
||||
$registered_users = $servers["registered-users"];
|
||||
$last_contact = $gserver["last_contact"];
|
||||
$last_failure = $gserver["last_failure"];
|
||||
$version = $gserver["version"];
|
||||
$platform = $gserver["platform"];
|
||||
$site_name = $gserver["site_name"];
|
||||
$info = $gserver["info"];
|
||||
$register_policy = $gserver["register_policy"];
|
||||
$registered_users = $gserver["registered-users"];
|
||||
|
||||
if (!$force && !self::updateNeeded($servers["created"], "", $last_failure, $last_contact)) {
|
||||
if (!$force && !self::updateNeeded($gserver["created"], "", $last_failure, $last_contact)) {
|
||||
logger("Use cached data for server ".$server_url, LOGGER_DEBUG);
|
||||
return ($last_contact >= $last_failure);
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ class PortableContact
|
|||
$last_contact = NULL_DATE;
|
||||
$last_failure = NULL_DATE;
|
||||
}
|
||||
logger("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$servers["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG);
|
||||
logger("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$gserver["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG);
|
||||
|
||||
$failure = false;
|
||||
$possible_failure = false;
|
||||
|
@ -876,7 +876,7 @@ class PortableContact
|
|||
|
||||
// Quit if there is a timeout.
|
||||
// But we want to make sure to only quit if we are mostly sure that this server url fits.
|
||||
if (DBM::is_result($servers) && ($orig_server_url == $server_url) &&
|
||||
if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
|
||||
($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
|
||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||
dba::update('gserver', array('last_failure' => datetime_convert()), array('nurl' => normalise_link($server_url)));
|
||||
|
|
|
@ -384,16 +384,15 @@ Class OnePoll
|
|||
// Have we seen it before?
|
||||
$fields = ['deleted', 'id'];
|
||||
$condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']];
|
||||
$r = dba::selectFirst('item', $fields, $condition);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$item = dba::selectFirst('item', $fields, $condition);
|
||||
if (DBM::is_result($item)) {
|
||||
logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
|
||||
|
||||
// Only delete when mails aren't automatically moved or deleted
|
||||
if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
|
||||
if ($meta->deleted && ! $r['deleted']) {
|
||||
if ($meta->deleted && ! $item['deleted']) {
|
||||
$fields = array('deleted' => true, 'changed' => datetime_convert());
|
||||
dba::update('item', $fields, array('id' => $r['id']));
|
||||
dba::update('item', $fields, array('id' => $item['id']));
|
||||
}
|
||||
|
||||
switch ($mailconf['action']) {
|
||||
|
|
|
@ -68,18 +68,11 @@ class Queue
|
|||
|
||||
|
||||
// delivering
|
||||
|
||||
$r = q(
|
||||
"SELECT * FROM `queue` WHERE `id` = %d LIMIT 1",
|
||||
intval($queue_id)
|
||||
);
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
$q_item = dba::selectFirst('queue', [], ['id' => $queue_id]);
|
||||
if (!DBM::is_result($q_item)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$q_item = $r[0];
|
||||
|
||||
$contact = dba::selectFirst('contact', [], ['id' => $q_item['cid']]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
remove_queue_item($q_item['id']);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue