Replace dba::select(limit => 1) by dba::selectOne
- Convert array declarations to new style
This commit is contained in:
		
					parent
					
						
							
								a2d3cee006
							
						
					
				
			
			
				commit
				
					
						da60893590
					
				
			
		
					 51 changed files with 206 additions and 219 deletions
				
			
		| 
						 | 
				
			
			@ -57,9 +57,8 @@ class OEmbed
 | 
			
		|||
 | 
			
		||||
		$a = get_app();
 | 
			
		||||
 | 
			
		||||
		$condition = array('url' => normalise_link($embedurl));
 | 
			
		||||
		$r = dba::select('oembed', array('content'), $condition, array('limit' => 1));
 | 
			
		||||
 | 
			
		||||
		$condition = ['url' => normalise_link($embedurl)];
 | 
			
		||||
		$r = dba::selectOne('oembed', ['content'], $condition);
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			$txt = $r["content"];
 | 
			
		||||
		} else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,7 +109,7 @@ class Cache
 | 
			
		|||
		// Frequently clear cache
 | 
			
		||||
		self::clear();
 | 
			
		||||
 | 
			
		||||
		$r = dba::select('cache', array('v'), array('k' => $key), array('limit' => 1));
 | 
			
		||||
		$r = dba::selectOne('cache', ['v'], ['k' => $key]);
 | 
			
		||||
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			$cached = $r['v'];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -97,7 +97,7 @@ class Config
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$ret = dba::select('config', array('v'), array('cat' => $family, 'k' => $key), array('limit' => 1));
 | 
			
		||||
		$ret = dba::selectOne('config', ['v'], ['cat' => $family, 'k' => $key]);
 | 
			
		||||
		if (DBM::is_result($ret)) {
 | 
			
		||||
			// manage array value
 | 
			
		||||
			$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -90,7 +90,7 @@ class PConfig
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$ret = dba::select('pconfig', array('v'), array('uid' => $uid, 'cat' => $family, 'k' => $key), array('limit' => 1));
 | 
			
		||||
		$ret = dba::selectOne('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']);
 | 
			
		||||
			$a->config[$uid][$family][$key] = $val;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -165,7 +165,7 @@ class Worker
 | 
			
		|||
	private static function highestPriority()
 | 
			
		||||
	{
 | 
			
		||||
		$condition = array("`executed` <= ? AND NOT `done`", NULL_DATE);
 | 
			
		||||
		$s = dba::select('workerqueue', array('priority'), $condition, array('limit' => 1, 'order' => array('priority')));
 | 
			
		||||
		$s = dba::selectOne('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
 | 
			
		||||
		if (DBM::is_result($s)) {
 | 
			
		||||
			return $s["priority"];
 | 
			
		||||
		} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -772,9 +772,9 @@ class Worker
 | 
			
		|||
			// Are there waiting processes with a higher priority than the currently highest?
 | 
			
		||||
			$result = dba::select(
 | 
			
		||||
				'workerqueue',
 | 
			
		||||
				array('id'),
 | 
			
		||||
				array("`executed` <= ? AND `priority` < ? AND NOT `done`", NULL_DATE, $highest_priority),
 | 
			
		||||
				array('limit' => $limit, 'order' => array('priority', 'created'), 'only_query' => true)
 | 
			
		||||
				['id'],
 | 
			
		||||
				["`executed` <= ? AND `priority` < ? AND NOT `done`", NULL_DATE, $highest_priority],
 | 
			
		||||
				['limit' => $limit, 'order' => ['priority', 'created']]
 | 
			
		||||
			);
 | 
			
		||||
 | 
			
		||||
			while ($id = dba::fetch($result)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -788,9 +788,9 @@ class Worker
 | 
			
		|||
				// Give slower processes some processing time
 | 
			
		||||
				$result = dba::select(
 | 
			
		||||
					'workerqueue',
 | 
			
		||||
					array('id'),
 | 
			
		||||
					array("`executed` <= ? AND `priority` > ? AND NOT `done`", NULL_DATE, $highest_priority),
 | 
			
		||||
					array('limit' => $limit, 'order' => array('priority', 'created'), 'only_query' => true)
 | 
			
		||||
					['id'],
 | 
			
		||||
					["`executed` <= ? AND `priority` > ? AND NOT `done`", NULL_DATE, $highest_priority],
 | 
			
		||||
					['limit' => $limit, 'order' => ['priority', 'created']]
 | 
			
		||||
				);
 | 
			
		||||
 | 
			
		||||
				while ($id = dba::fetch($result)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -807,9 +807,9 @@ class Worker
 | 
			
		|||
		if (!$found) {
 | 
			
		||||
			$result = dba::select(
 | 
			
		||||
				'workerqueue',
 | 
			
		||||
				array('id'),
 | 
			
		||||
				array("`executed` <= ? AND NOT `done`", NULL_DATE),
 | 
			
		||||
				array('limit' => $limit, 'order' => array('priority', 'created'), 'only_query' => true)
 | 
			
		||||
				['id'],
 | 
			
		||||
				["`executed` <= ? AND NOT `done`", NULL_DATE],
 | 
			
		||||
				['limit' => $limit, 'order' => ['priority', 'created']]
 | 
			
		||||
			);
 | 
			
		||||
 | 
			
		||||
			while ($id = dba::fetch($result)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -103,7 +103,7 @@ class Contact extends BaseObject
 | 
			
		|||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$user = dba::select('user', ['uid', 'username', 'nickname'], ['uid' => $uid], ['limit' => 1]);
 | 
			
		||||
		$user = dba::selectOne('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
 | 
			
		||||
		if (!DBM::is_result($user)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +145,7 @@ 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::select('contact', array('uid'), array('id' => $id, 'self' => false), array('limit' => 1));
 | 
			
		||||
		$r = dba::selectOne('contact', ['uid'], ['id' => $id, 'self' => false]);
 | 
			
		||||
 | 
			
		||||
		if (!DBM::is_result($r) || !intval($r['uid'])) {
 | 
			
		||||
			return;
 | 
			
		||||
| 
						 | 
				
			
			@ -490,7 +490,7 @@ class Contact extends BaseObject
 | 
			
		|||
				return $menu;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$r = dba::select('contact', array(), array('nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid), array('limit' => 1));
 | 
			
		||||
			$r = dba::selectOne('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
 | 
			
		||||
			if ($r) {
 | 
			
		||||
				return self::photoMenu($r, $uid);
 | 
			
		||||
			} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -653,18 +653,18 @@ class Contact extends BaseObject
 | 
			
		|||
 | 
			
		||||
		/// @todo Verify if we can't use Contact::getDetailsByUrl instead of the following
 | 
			
		||||
		// We first try the nurl (http://server.tld/nick), most common case
 | 
			
		||||
		$contact = dba::select('contact', array('id', 'avatar-date'), array('nurl' => normalise_link($url), 'uid' => $uid), array('limit' => 1));
 | 
			
		||||
		$contact = dba::selectOne('contact', ['id', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
 | 
			
		||||
 | 
			
		||||
		// Then the addr (nick@server.tld)
 | 
			
		||||
		if (!DBM::is_result($contact)) {
 | 
			
		||||
			$contact = dba::select('contact', array('id', 'avatar-date'), array('addr' => $url, 'uid' => $uid), array('limit' => 1));
 | 
			
		||||
			$contact = dba::selectOne('contact', ['id', 'avatar-date'], ['addr' => $url, 'uid' => $uid]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Then the alias (which could be anything)
 | 
			
		||||
		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::select('contact', array('id', 'avatar', 'avatar-date'), array('`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid), array('limit' => 1));
 | 
			
		||||
			$r = dba::selectOne('contact', ['id', 'avatar', 'avatar-date'], ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid]);
 | 
			
		||||
			$contact = dba::fetch($r);
 | 
			
		||||
			dba::close($r);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -697,7 +697,7 @@ class Contact extends BaseObject
 | 
			
		|||
			}
 | 
			
		||||
 | 
			
		||||
			// Get data from the gcontact table
 | 
			
		||||
			$gcontacts = dba::select('gcontact', array('name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'), array('nurl' => normalise_link($url)), array('limit' => 1));
 | 
			
		||||
			$gcontacts = dba::selectOne('gcontact', ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'], ['nurl' => normalise_link($url)]);
 | 
			
		||||
			if (!DBM::is_result($gcontacts)) {
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -735,7 +735,7 @@ class Contact extends BaseObject
 | 
			
		|||
			$contact_id = $contacts[0]["id"];
 | 
			
		||||
 | 
			
		||||
			// Update the newly created contact from data in the gcontact table
 | 
			
		||||
			$gcontact = dba::select('gcontact', array('location', 'about', 'keywords', 'gender'), array('nurl' => normalise_link($data["url"])), array('limit' => 1));
 | 
			
		||||
			$gcontact = dba::selectOne('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => normalise_link($data["url"])]);
 | 
			
		||||
			if (DBM::is_result($gcontact)) {
 | 
			
		||||
				// Only use the information when the probing hadn't fetched these values
 | 
			
		||||
				if ($data['keywords'] != '') {
 | 
			
		||||
| 
						 | 
				
			
			@ -758,8 +758,8 @@ class Contact extends BaseObject
 | 
			
		|||
 | 
			
		||||
		self::updateAvatar($data["photo"], $uid, $contact_id);
 | 
			
		||||
 | 
			
		||||
		$fields = array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey');
 | 
			
		||||
		$contact = dba::select('contact', $fields, array('id' => $contact_id), array('limit' => 1));
 | 
			
		||||
		$fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey'];
 | 
			
		||||
		$contact = dba::selectOne('contact', $fields, ['id' => $contact_id]);
 | 
			
		||||
 | 
			
		||||
		// This condition should always be true
 | 
			
		||||
		if (!DBM::is_result($contact)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -817,7 +817,7 @@ class Contact extends BaseObject
 | 
			
		|||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$blocked = dba::select('contact', array('blocked'), array('id' => $cid), array('limit' => 1));
 | 
			
		||||
		$blocked = dba::selectOne('contact', ['blocked'], ['id' => $cid]);
 | 
			
		||||
		if (!DBM::is_result($blocked)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -837,7 +837,7 @@ class Contact extends BaseObject
 | 
			
		|||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$hidden = dba::select('contact', array('hidden'), array('id' => $cid), array('limit' => 1));
 | 
			
		||||
		$hidden = dba::selectOne('contact', ['hidden'], ['id' => $cid]);
 | 
			
		||||
		if (!DBM::is_result($hidden)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -980,7 +980,7 @@ 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::select('contact', array('avatar', 'photo', 'thumb', 'micro', 'nurl'), array('id' => $cid), array('limit' => 1));
 | 
			
		||||
		$r = dba::selectOne('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
 | 
			
		||||
		if (!DBM::is_result($r)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -999,7 +999,7 @@ class Contact extends BaseObject
 | 
			
		|||
 | 
			
		||||
				// Update the public contact (contact id = 0)
 | 
			
		||||
				if ($uid != 0) {
 | 
			
		||||
					$pcontact = dba::select('contact', array('id'), array('nurl' => $r[0]['nurl']), array('limit' => 1));
 | 
			
		||||
					$pcontact = dba::selectOne('contact', ['id'], ['nurl' => $r[0]['nurl']]);
 | 
			
		||||
					if (DBM::is_result($pcontact)) {
 | 
			
		||||
						self::updateAvatar($avatar, 0, $pcontact['id'], $force);
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -1023,7 +1023,7 @@ class Contact extends BaseObject
 | 
			
		|||
		This will reliably kill your communication with Friendica contacts.
 | 
			
		||||
		*/
 | 
			
		||||
 | 
			
		||||
		$r = dba::select('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id], ['limit' => 1]);
 | 
			
		||||
		$r = dba::selectOne('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id]);
 | 
			
		||||
		if (!DBM::is_result($r)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1246,7 +1246,7 @@ class Contact extends BaseObject
 | 
			
		|||
			);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$r = dba::select('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid], ['limit' => 1]);
 | 
			
		||||
		$r = dba::selectOne('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
 | 
			
		||||
 | 
			
		||||
		if (!DBM::is_result($r)) {
 | 
			
		||||
			$result['message'] .= t('Unable to retrieve contact information.') . EOL;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -888,7 +888,7 @@ class GContact
 | 
			
		|||
						'network', 'bd', 'gender',
 | 
			
		||||
						'keywords', 'alias', 'contact-type',
 | 
			
		||||
						'url', 'location', 'about');
 | 
			
		||||
				$old_contact = dba::select('contact', $fields, array('id' => $r[0]["id"]), array('limit' => 1));
 | 
			
		||||
				$old_contact = dba::selectOne('contact', $fields, ['id' => $r[0]["id"]]);
 | 
			
		||||
 | 
			
		||||
				// Update it with the current values
 | 
			
		||||
				$fields = array('name' => $contact['name'], 'nick' => $contact['nick'],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ class Group extends BaseObject
 | 
			
		|||
				// all the old members are gone, but the group remains so we don't break any security
 | 
			
		||||
				// access lists. What we're doing here is reviving the dead group, but old content which
 | 
			
		||||
				// was restricted to this group may now be seen by the new group members.
 | 
			
		||||
				$group = dba::select('group', ['deleted'], ['id' => $gid], ['limit' => 1]);
 | 
			
		||||
				$group = dba::selectOne('group', ['deleted'], ['id' => $gid]);
 | 
			
		||||
				if (DBM::is_result($group) && $group['deleted']) {
 | 
			
		||||
					dba::update('group', ['deleted' => 0], ['gid' => $gid]);
 | 
			
		||||
					notice(t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
 | 
			
		||||
| 
						 | 
				
			
			@ -120,7 +120,7 @@ class Group extends BaseObject
 | 
			
		|||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$group = dba::select('group', ['id'], ['uid' => $uid, 'name' => $name], ['limit' => 1]);
 | 
			
		||||
		$group = dba::selectOne('group', ['id'], ['uid' => $uid, 'name' => $name]);
 | 
			
		||||
		if (DBM::is_result($group)) {
 | 
			
		||||
			return $group['id'];
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -139,13 +139,13 @@ class Group extends BaseObject
 | 
			
		|||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$group = dba::select('group', ['uid'], ['gid' => $gid], ['limit' => 1]);
 | 
			
		||||
		$group = dba::selectOne('group', ['uid'], ['gid' => $gid]);
 | 
			
		||||
		if (!DBM::is_result($group)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// remove group from default posting lists
 | 
			
		||||
		$user = dba::select('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']], ['limit' => 1]);
 | 
			
		||||
		$user = dba::selectOne('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
 | 
			
		||||
		if (DBM::is_result($user)) {
 | 
			
		||||
			$change = false;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,14 +38,14 @@ 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::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
 | 
			
		||||
		$r = dba::selectOne('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			$guid = $r['guid'];
 | 
			
		||||
		} else {
 | 
			
		||||
			$guid = get_guid();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$x = dba::select('photo', array('id'), array('resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale), array('limit' => 1));
 | 
			
		||||
		$x = dba::selectOne('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
 | 
			
		||||
 | 
			
		||||
		$fields = array(
 | 
			
		||||
			'uid' => $uid,
 | 
			
		||||
| 
						 | 
				
			
			@ -88,8 +88,8 @@ class Photo
 | 
			
		|||
	 */
 | 
			
		||||
	public static function importProfilePhoto($photo, $uid, $cid, $quit_on_error = false)
 | 
			
		||||
	{
 | 
			
		||||
		$r = dba::select(
 | 
			
		||||
			'photo', array('resource-id'), array('uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos'), array('limit' => 1)
 | 
			
		||||
		$r = dba::selectOne(
 | 
			
		||||
			'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		if (DBM::is_result($r) && strlen($r['resource-id'])) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,7 +84,7 @@ class User
 | 
			
		|||
			return $default_group;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$user = dba::select('user', ['def_gid'], ['uid' => $uid], ['limit' => 1]);
 | 
			
		||||
		$user = dba::selectOne('user', ['def_gid'], ['uid' => $uid]);
 | 
			
		||||
 | 
			
		||||
		if (DBM::is_result($user)) {
 | 
			
		||||
			$default_group = $user["def_gid"];
 | 
			
		||||
| 
						 | 
				
			
			@ -112,16 +112,14 @@ class User
 | 
			
		|||
		if (is_object($user_info)) {
 | 
			
		||||
			$user = (array) $user_info;
 | 
			
		||||
		} elseif (is_int($user_info)) {
 | 
			
		||||
			$user = dba::select('user',
 | 
			
		||||
				['uid', 'password'],
 | 
			
		||||
			$user = dba::selectOne('user', ['uid', 'password'],
 | 
			
		||||
				[
 | 
			
		||||
					'uid' => $user_info,
 | 
			
		||||
					'blocked' => 0,
 | 
			
		||||
					'account_expired' => 0,
 | 
			
		||||
					'account_removed' => 0,
 | 
			
		||||
					'verified' => 1
 | 
			
		||||
				],
 | 
			
		||||
				['limit' => 1]
 | 
			
		||||
				]
 | 
			
		||||
			);
 | 
			
		||||
		} elseif (is_string($user_info)) {
 | 
			
		||||
			$user = dba::fetch_first('SELECT `uid`, `password`
 | 
			
		||||
| 
						 | 
				
			
			@ -330,7 +328,7 @@ class User
 | 
			
		|||
 | 
			
		||||
		if ($insert_result) {
 | 
			
		||||
			$uid = dba::lastInsertId();
 | 
			
		||||
			$user = dba::select('user', [], ['uid' => $uid], ['limit' => 1]);
 | 
			
		||||
			$user = dba::selectOne('user', [], ['uid' => $uid]);
 | 
			
		||||
		} else {
 | 
			
		||||
			throw new Exception(t('An error occurred during registration. Please try again.'));
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -532,7 +530,7 @@ class User
 | 
			
		|||
 | 
			
		||||
		logger('Removing user: ' . $uid);
 | 
			
		||||
 | 
			
		||||
		$user = dba::select('user', [], ['uid' => $uid], ['limit' => 1]);
 | 
			
		||||
		$user = dba::selectOne('user', [], ['uid' => $uid]);
 | 
			
		||||
 | 
			
		||||
		call_hooks('remove_user', $user);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,7 +99,7 @@ class Login extends BaseModule
 | 
			
		|||
			} else {
 | 
			
		||||
				$user_id = User::authenticate(trim($_POST['username']), trim($_POST['password']));
 | 
			
		||||
				if ($user_id) {
 | 
			
		||||
					$record = dba::select('user', [], ['uid' => $user_id], ['limit' => 1]);
 | 
			
		||||
					$record = dba::selectOne('user', [], ['uid' => $user_id]);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -141,18 +141,15 @@ class Login extends BaseModule
 | 
			
		|||
			$data = json_decode($_COOKIE["Friendica"]);
 | 
			
		||||
			if (isset($data->uid)) {
 | 
			
		||||
 | 
			
		||||
				$user = dba::select('user',
 | 
			
		||||
					[],
 | 
			
		||||
				$user = dba::selectOne('user', [],
 | 
			
		||||
					[
 | 
			
		||||
						'uid'             => $data->uid,
 | 
			
		||||
						'blocked'         => false,
 | 
			
		||||
						'account_expired' => false,
 | 
			
		||||
						'account_removed' => false,
 | 
			
		||||
						'verified'        => true,
 | 
			
		||||
					],
 | 
			
		||||
					['limit' => 1]
 | 
			
		||||
					]
 | 
			
		||||
				);
 | 
			
		||||
 | 
			
		||||
				if (DBM::is_result($user)) {
 | 
			
		||||
					if ($data->hash != cookie_hash($user)) {
 | 
			
		||||
						logger("Hash for user " . $data->uid . " doesn't fit.");
 | 
			
		||||
| 
						 | 
				
			
			@ -199,16 +196,14 @@ class Login extends BaseModule
 | 
			
		|||
					goaway(self::getApp()->get_baseurl());
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				$user = dba::select('user',
 | 
			
		||||
					[],
 | 
			
		||||
				$user = dba::selectOne('user', [],
 | 
			
		||||
					[
 | 
			
		||||
						'uid'             => $_SESSION['uid'],
 | 
			
		||||
						'blocked'         => false,
 | 
			
		||||
						'account_expired' => false,
 | 
			
		||||
						'account_removed' => false,
 | 
			
		||||
						'verified'        => true,
 | 
			
		||||
					],
 | 
			
		||||
					['limit' => 1]
 | 
			
		||||
					]
 | 
			
		||||
				);
 | 
			
		||||
				if (!DBM::is_result($user)) {
 | 
			
		||||
					nuke_session();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ class FKOAuth1 extends OAuthServer
 | 
			
		|||
	{
 | 
			
		||||
		logger("FKOAuth1::loginUser $uid");
 | 
			
		||||
		$a = get_app();
 | 
			
		||||
		$record = dba::select('user', array(), array('uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1), array('limit' => 1));
 | 
			
		||||
		$record = dba::selectOne('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
 | 
			
		||||
 | 
			
		||||
		if (!DBM::is_result($record)) {
 | 
			
		||||
			logger('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), LOGGER_DEBUG);
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ class FKOAuth1 extends OAuthServer
 | 
			
		|||
			$a->timezone = $a->user['timezone'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$r = dba::select('contact', array(), array('uid' => $_SESSION['uid'], 'self' => 1), array('limit' => 1));
 | 
			
		||||
		$r = dba::selectOne('contact', [], ['uid' => $_SESSION['uid'], 'self' => 1]);
 | 
			
		||||
		
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			$a->contact = $r;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,7 +88,7 @@ class FKOAuthDataStore extends OAuthDataStore
 | 
			
		|||
	 */
 | 
			
		||||
	public function lookup_nonce($consumer, $token, $nonce, $timestamp)
 | 
			
		||||
	{
 | 
			
		||||
		$r = dba::select('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp], ['limit' => 1]);
 | 
			
		||||
		$r = dba::selectOne('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp]);
 | 
			
		||||
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			return new \OAuthToken($r['id'], $r['secret']);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -406,7 +406,7 @@ class Probe
 | 
			
		|||
 | 
			
		||||
				$condition = array('nurl' => normalise_link($data["url"]));
 | 
			
		||||
 | 
			
		||||
				$old_fields = dba::select('gcontact', $fieldnames, $condition, array('limit' => 1));
 | 
			
		||||
				$old_fields = dba::selectOne('gcontact', $fieldnames, $condition);
 | 
			
		||||
 | 
			
		||||
				dba::update('gcontact', $fields, $condition, $old_fields);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -439,7 +439,7 @@ class Probe
 | 
			
		|||
 | 
			
		||||
				$condition = array('nurl' => normalise_link($data["url"]), 'self' => false, 'uid' => 0);
 | 
			
		||||
 | 
			
		||||
				$old_fields = dba::select('contact', $fieldnames, $condition, array('limit' => 1));
 | 
			
		||||
				$old_fields = dba::selectOne('contact', $fieldnames, $condition);
 | 
			
		||||
 | 
			
		||||
				dba::update('contact', $fields, $condition, $old_fields);
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -261,7 +261,7 @@ class Post extends BaseObject
 | 
			
		|||
					'classundo' => $item['starred'] ? "" : "hidden",
 | 
			
		||||
					'starred'   => t('starred'),
 | 
			
		||||
				);
 | 
			
		||||
				$r = dba::select('thread', array('ignored'), array('uid' => $item['uid'], 'iid' => $item['id']), array('limit' => 1));
 | 
			
		||||
				$r = dba::selectOne('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
 | 
			
		||||
				if (DBM::is_result($r)) {
 | 
			
		||||
					$ignore = array(
 | 
			
		||||
						'do'        => t("ignore thread"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2015,7 +2015,7 @@ class Diaspora
 | 
			
		|||
 | 
			
		||||
		// like on comments have the comment as parent. So we need to fetch the toplevel parent
 | 
			
		||||
		if ($parent_item["id"] != $parent_item["parent"]) {
 | 
			
		||||
			$toplevel = dba::select('item', array('origin'), array('id' => $parent_item["parent"]), array('limit' => 1));
 | 
			
		||||
			$toplevel = dba::selectOne('item', ['origin'], ['id' => $parent_item["parent"]]);
 | 
			
		||||
			$origin = $toplevel["origin"];
 | 
			
		||||
		} else {
 | 
			
		||||
			$origin = $parent_item["origin"];
 | 
			
		||||
| 
						 | 
				
			
			@ -2317,7 +2317,7 @@ class Diaspora
 | 
			
		|||
 | 
			
		||||
				$arr["last-child"] = 1;
 | 
			
		||||
 | 
			
		||||
				$user = dba::select('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]], ['limit' => 1]);
 | 
			
		||||
				$user = dba::selectOne('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]]);
 | 
			
		||||
 | 
			
		||||
				$arr["allow_cid"] = $user["allow_cid"];
 | 
			
		||||
				$arr["allow_gid"] = $user["allow_gid"];
 | 
			
		||||
| 
						 | 
				
			
			@ -2741,7 +2741,7 @@ class Diaspora
 | 
			
		|||
 | 
			
		||||
		while ($item = dba::fetch($r)) {
 | 
			
		||||
			// Fetch the parent item
 | 
			
		||||
			$parent = dba::select('item', array('author-link', 'origin'), array('id' => $item["parent"]), array('limit' => 1));
 | 
			
		||||
			$parent = dba::selectOne('item', ['author-link', 'origin'], ['id' => $item["parent"]]);
 | 
			
		||||
 | 
			
		||||
			// Only delete it if the parent author really fits
 | 
			
		||||
			if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) {
 | 
			
		||||
| 
						 | 
				
			
			@ -3255,7 +3255,7 @@ class Diaspora
 | 
			
		|||
		// If the item belongs to a user, we take this user id.
 | 
			
		||||
		if ($item['uid'] == 0) {
 | 
			
		||||
			$condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false];
 | 
			
		||||
			$first_user = dba::select('user', ['uid'], $condition, ['limit' => 1]);
 | 
			
		||||
			$first_user = dba::selectOne('user', ['uid'], $condition);
 | 
			
		||||
			$owner = User::getOwnerDataById($first_user['uid']);
 | 
			
		||||
		} else {
 | 
			
		||||
			$owner = User::getOwnerDataById($item['uid']);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -254,7 +254,7 @@ class Feed {
 | 
			
		|||
			if (!$simulate) {
 | 
			
		||||
				$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
 | 
			
		||||
					$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
 | 
			
		||||
				$previous = dba::select('item', ['id'], $condition, ['limit' => 1]);
 | 
			
		||||
				$previous = dba::selectOne('item', ['id'], $condition);
 | 
			
		||||
				if (DBM::is_result($previous)) {
 | 
			
		||||
					logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
 | 
			
		||||
					continue;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,9 +70,9 @@ class OStatus
 | 
			
		|||
		$found = false;
 | 
			
		||||
 | 
			
		||||
		if ($aliaslink != '') {
 | 
			
		||||
			$condition = array("`uid` = ? AND `alias` = ? AND `network` != ?",
 | 
			
		||||
					$importer["uid"], $aliaslink, NETWORK_STATUSNET);
 | 
			
		||||
			$r = dba::select('contact', array(), $condition, array('limit' => 1));
 | 
			
		||||
			$condition = ["`uid` = ? AND `alias` = ? AND `network` != ?",
 | 
			
		||||
					$importer["uid"], $aliaslink, NETWORK_STATUSNET];
 | 
			
		||||
			$r = dba::selectOne('contact', [], $condition);
 | 
			
		||||
 | 
			
		||||
			if (DBM::is_result($r)) {
 | 
			
		||||
				$found = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -89,9 +89,9 @@ class OStatus
 | 
			
		|||
				$aliaslink = $author["author-link"];
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$condition = array("`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
 | 
			
		||||
					normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET);
 | 
			
		||||
			$r = dba::select('contact', array(), $condition, array('limit' => 1));
 | 
			
		||||
			$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
 | 
			
		||||
					normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET];
 | 
			
		||||
			$r = dba::selectOne('contact', [], $condition);
 | 
			
		||||
 | 
			
		||||
			if (DBM::is_result($r)) {
 | 
			
		||||
				$found = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -104,9 +104,9 @@ class OStatus
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		if (!$found && ($addr != "")) {
 | 
			
		||||
			$condition = array("`uid` = ? AND `addr` = ? AND `network` != ?",
 | 
			
		||||
					$importer["uid"], $addr, NETWORK_STATUSNET);
 | 
			
		||||
			$r = dba::select('contact', array(), $condition, array('limit' => 1));
 | 
			
		||||
			$condition = ["`uid` = ? AND `addr` = ? AND `network` != ?",
 | 
			
		||||
					$importer["uid"], $addr, NETWORK_STATUSNET];
 | 
			
		||||
			$r = dba::selectOne('contact', [], $condition);
 | 
			
		||||
 | 
			
		||||
			if (DBM::is_result($r)) {
 | 
			
		||||
				$found = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -207,8 +207,8 @@ class OStatus
 | 
			
		|||
			$cid = Contact::getIdForURL($aliaslink, 0);
 | 
			
		||||
 | 
			
		||||
			if ($cid) {
 | 
			
		||||
				$fields = array('url', 'nurl', 'name', 'nick', 'alias', 'about', 'location');
 | 
			
		||||
				$old_contact = dba::select('contact', $fields, array('id' => $cid), array('limit' => 1));
 | 
			
		||||
				$fields = ['url', 'nurl', 'name', 'nick', 'alias', 'about', 'location'];
 | 
			
		||||
				$old_contact = dba::selectOne('contact', $fields, ['id' => $cid]);
 | 
			
		||||
 | 
			
		||||
				// Update it with the current values
 | 
			
		||||
				$fields = array('url' => $author["author-link"], 'name' => $contact["name"],
 | 
			
		||||
| 
						 | 
				
			
			@ -541,8 +541,8 @@ class OStatus
 | 
			
		|||
	 */
 | 
			
		||||
	private static function deleteNotice($item)
 | 
			
		||||
	{
 | 
			
		||||
		$condition = array('uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']);
 | 
			
		||||
		$deleted = dba::select('item', array('id', 'parent-uri'), $condition, array('limit' => 1));
 | 
			
		||||
		$condition = ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']];
 | 
			
		||||
		$deleted = dba::selectOne('item', ['id', 'parent-uri'], $condition);
 | 
			
		||||
		if (!DBM::is_result($deleted)) {
 | 
			
		||||
			logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it. ");
 | 
			
		||||
			return;
 | 
			
		||||
| 
						 | 
				
			
			@ -895,8 +895,8 @@ class OStatus
 | 
			
		|||
	 */
 | 
			
		||||
	private static function fetchRelated($related, $related_uri, $importer)
 | 
			
		||||
	{
 | 
			
		||||
		$condition = array('`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON);
 | 
			
		||||
		$conversation = dba::select('conversation', array('source', 'protocol'), $condition,  array('limit' => 1));
 | 
			
		||||
		$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
 | 
			
		||||
		$conversation = dba::selectOne('conversation', ['source', 'protocol'], $condition);
 | 
			
		||||
		if (DBM::is_result($conversation)) {
 | 
			
		||||
			$stored = true;
 | 
			
		||||
			$xml = $conversation['source'];
 | 
			
		||||
| 
						 | 
				
			
			@ -975,8 +975,8 @@ class OStatus
 | 
			
		|||
 | 
			
		||||
		// Finally we take the data that we fetched from "ostatus:conversation"
 | 
			
		||||
		if ($xml == '') {
 | 
			
		||||
			$condition = array('item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV);
 | 
			
		||||
			$conversation = dba::select('conversation', array('source'), $condition,  array('limit' => 1));
 | 
			
		||||
			$condition = ['item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV];
 | 
			
		||||
			$conversation = dba::selectOne('conversation', ['source'], $condition);
 | 
			
		||||
			if (DBM::is_result($conversation)) {
 | 
			
		||||
				$stored = true;
 | 
			
		||||
				logger('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,7 +66,7 @@ class PortableContact
 | 
			
		|||
 | 
			
		||||
		if ($cid) {
 | 
			
		||||
			if (!$url || !$uid) {
 | 
			
		||||
				$r = dba::select('contact', ['poco', 'uid'], ['id' => $cid], ['limit' => 1]);
 | 
			
		||||
				$r = dba::selectOne('contact', ['poco', 'uid'], ['id' => $cid]);
 | 
			
		||||
				if (DBM::is_result($r)) {
 | 
			
		||||
					$url = $r['poco'];
 | 
			
		||||
					$uid = $r['uid'];
 | 
			
		||||
| 
						 | 
				
			
			@ -813,7 +813,7 @@ class PortableContact
 | 
			
		|||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$servers = dba::select('gserver', [], ['nurl' => normalise_link($server_url)], ['limit' => 1]);
 | 
			
		||||
		$servers = dba::selectOne('gserver', [], ['nurl' => normalise_link($server_url)]);
 | 
			
		||||
		if (DBM::is_result($servers)) {
 | 
			
		||||
			if ($servers["created"] <= NULL_DATE) {
 | 
			
		||||
				$fields = ['created' => datetime_convert()];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -226,7 +226,7 @@ class ExAuth
 | 
			
		|||
		if ($a->get_hostname() == $aCommand[2]) {
 | 
			
		||||
			$this->writeLog(LOG_INFO, 'internal auth for ' . $sUser . '@' . $aCommand[2]);
 | 
			
		||||
 | 
			
		||||
			$aUser = dba::select('user', ['uid', 'password'], ['nickname' => $sUser], ['limit' => 1]);
 | 
			
		||||
			$aUser = dba::selectOne('user', ['uid', 'password'], ['nickname' => $sUser]);
 | 
			
		||||
			if (DBM::is_result($aUser)) {
 | 
			
		||||
				$uid = $aUser['uid'];
 | 
			
		||||
				$success = User::authenticate($aUser, $aCommand[3]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -126,7 +126,7 @@ class Lock
 | 
			
		|||
 | 
			
		||||
		do {
 | 
			
		||||
			dba::lock('locks');
 | 
			
		||||
			$lock = dba::select('locks', array('locked', 'pid'), array('name' => $fn_name), array('limit' => 1));
 | 
			
		||||
			$lock = dba::selectOne('locks', ['locked', 'pid'], ['name' => $fn_name]);
 | 
			
		||||
 | 
			
		||||
			if (DBM::is_result($lock)) {
 | 
			
		||||
				if ($lock['locked']) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ class Expire {
 | 
			
		|||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		} elseif (intval($param) > 0) {
 | 
			
		||||
			$user = dba::select('user', array('uid', 'username', 'expire'), array('uid' => $param), array('limit' => 1));
 | 
			
		||||
			$user = dba::selectOne('user', ['uid', 'username', 'expire'], ['uid' => $param]);
 | 
			
		||||
			if (DBM::is_result($user)) {
 | 
			
		||||
				logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG);
 | 
			
		||||
				item_expire($user['uid'], $user['expire']);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -265,9 +265,9 @@ class Notifier {
 | 
			
		|||
				($owner['id'] != $target_item['contact-id']) &&
 | 
			
		||||
				($target_item['uri'] === $target_item['parent-uri'])) {
 | 
			
		||||
 | 
			
		||||
				$fields = array('forum', 'prv');
 | 
			
		||||
				$condition = array('id' => $target_item['contact-id']);
 | 
			
		||||
				$contact = dba::select('contact', $fields, $condition, array('limit' => 1));
 | 
			
		||||
				$fields = ['forum', 'prv'];
 | 
			
		||||
				$condition = ['id' => $target_item['contact-id']];
 | 
			
		||||
				$contact = dba::selectOne('contact', $fields, $condition);
 | 
			
		||||
				if (!DBM::is_result($contact)) {
 | 
			
		||||
					// Should never happen
 | 
			
		||||
					return false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ Class OnePoll
 | 
			
		|||
 | 
			
		||||
		$d = datetime_convert();
 | 
			
		||||
 | 
			
		||||
		$contact = dba::select('contact', [], ['id' => $contact_id], ['limit' => 1]);
 | 
			
		||||
		$contact = dba::selectOne('contact', [], ['id' => $contact_id]);
 | 
			
		||||
		if (!DBM::is_result($contact)) {
 | 
			
		||||
			logger('Contact not found or cannot be used.');
 | 
			
		||||
			return;
 | 
			
		||||
| 
						 | 
				
			
			@ -339,14 +339,14 @@ Class OnePoll
 | 
			
		|||
			logger("Mail: Enabled", LOGGER_DEBUG);
 | 
			
		||||
 | 
			
		||||
			$mbox = null;
 | 
			
		||||
			$x = dba::select('user', array('prvkey'), array('uid' => $importer_uid), array('limit' => 1));
 | 
			
		||||
			$user = dba::selectOne('user', ['prvkey'], ['uid' => $importer_uid]);
 | 
			
		||||
 | 
			
		||||
			$condition = array("`server` != '' AND `uid` = ?", $importer_uid);
 | 
			
		||||
			$mailconf = dba::select('mailacct', array(), $condition, array('limit' => 1));
 | 
			
		||||
			if (DBM::is_result($x) && DBM::is_result($mailconf)) {
 | 
			
		||||
			$condition = ["`server` != '' AND `uid` = ?", $importer_uid];
 | 
			
		||||
			$mailconf = dba::selectOne('mailacct', [], $condition);
 | 
			
		||||
			if (DBM::is_result($user) && DBM::is_result($mailconf)) {
 | 
			
		||||
				$mailbox = Email::constructMailboxName($mailconf);
 | 
			
		||||
				$password = '';
 | 
			
		||||
				openssl_private_decrypt(hex2bin($mailconf['pass']), $password, $x['prvkey']);
 | 
			
		||||
				openssl_private_decrypt(hex2bin($mailconf['pass']), $password, $user['prvkey']);
 | 
			
		||||
				$mbox = Email::connect($mailbox, $mailconf['user'], $password);
 | 
			
		||||
				unset($password);
 | 
			
		||||
				logger("Mail: Connect to " . $mailconf['user']);
 | 
			
		||||
| 
						 | 
				
			
			@ -382,9 +382,9 @@ Class OnePoll
 | 
			
		|||
							$datarray['uri'] = Email::msgid2iri(trim($meta->message_id, '<>'));
 | 
			
		||||
 | 
			
		||||
							// Have we seen it before?
 | 
			
		||||
							$fields = array('deleted', 'id');
 | 
			
		||||
							$condition = array('uid' => $importer_uid, 'uri' => $datarray['uri']);
 | 
			
		||||
							$r = dba::select('item', $fields, $condition, array('limit' => 1));
 | 
			
		||||
							$fields = ['deleted', 'id'];
 | 
			
		||||
							$condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']];
 | 
			
		||||
							$r = dba::selectOne('item', $fields, $condition);
 | 
			
		||||
 | 
			
		||||
							if (DBM::is_result($r)) {
 | 
			
		||||
								logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ class Queue
 | 
			
		|||
 | 
			
		||||
		$q_item = $r[0];
 | 
			
		||||
 | 
			
		||||
		$contact = dba::select('contact', [], ['id' => $q_item['cid']], ['limit' => 1]);
 | 
			
		||||
		$contact = dba::selectOne('contact', [], ['id' => $q_item['cid']]);
 | 
			
		||||
		if (!DBM::is_result($contact)) {
 | 
			
		||||
			remove_queue_item($q_item['id']);
 | 
			
		||||
			return;
 | 
			
		||||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ class Queue
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$user = dba::select('user', [], ['uid' => $contact['uid']], ['limit' => 1]);
 | 
			
		||||
		$user = dba::selectOne('user', [], ['uid' => $contact['uid']]);
 | 
			
		||||
		if (!DBM::is_result($user)) {
 | 
			
		||||
			remove_queue_item($q_item['id']);
 | 
			
		||||
			return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue