Merge pull request #3622 from annando/new-dba
Enhanced dba functions, several replaced database calls
This commit is contained in:
commit
e6e8ebbac5
16 changed files with 183 additions and 367 deletions
|
@ -101,12 +101,12 @@ function network_to_name($s, $profile = "") {
|
||||||
$networkname = str_replace($search, $replace, $s);
|
$networkname = str_replace($search, $replace, $s);
|
||||||
|
|
||||||
if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
|
if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
|
||||||
$r = q("SELECT `gserver`.`platform` FROM `gcontact`
|
$r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
|
||||||
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
|
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
|
||||||
WHERE `gcontact`.`nurl` = '%s' AND `platform` != ''",
|
WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
|
||||||
dbesc(normalise_link($profile)));
|
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
$networkname = $r[0]["platform"];
|
$networkname = $r['platform'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -921,10 +921,11 @@ function best_link_url($item, &$sparkle, $ssl_state = false) {
|
||||||
$clean_url = normalise_link($item['author-link']);
|
$clean_url = normalise_link($item['author-link']);
|
||||||
|
|
||||||
if (local_user()) {
|
if (local_user()) {
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `nurl` = '%s' AND NOT `pending` LIMIT 1",
|
$r = dba::select('contact', array('id'),
|
||||||
dbesc(NETWORK_DFRN), intval(local_user()), dbesc(normalise_link($clean_url)));
|
array('network' => NETWORK_DFRN, 'uid' => local_user(), 'nurl' => normalise_link($clean_url), 'pending' => false),
|
||||||
|
array('limit' => 1));
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
$best_url = 'redir/' . $r[0]['id'];
|
$best_url = 'redir/' . $r['id'];
|
||||||
$sparkle = true;
|
$sparkle = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -940,7 +941,6 @@ function best_link_url($item, &$sparkle, $ssl_state = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! function_exists('item_photo_menu')) {
|
|
||||||
function item_photo_menu($item) {
|
function item_photo_menu($item) {
|
||||||
$ssl_state = false;
|
$ssl_state = false;
|
||||||
|
|
||||||
|
@ -970,12 +970,11 @@ function item_photo_menu($item) {
|
||||||
$cid = 0;
|
$cid = 0;
|
||||||
$network = '';
|
$network = '';
|
||||||
$rel = 0;
|
$rel = 0;
|
||||||
$r = q("SELECT `id`, `network`, `rel` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
|
$r = dba::select('contact', array('id', 'network', 'rel'), array('uid' => local_user(), 'nurl' => normalise_link($item['author-link'])), array('limit' => 1));
|
||||||
intval(local_user()), dbesc(normalise_link($item['author-link'])));
|
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
$cid = $r[0]['id'];
|
$cid = $r['id'];
|
||||||
$network = $r[0]['network'];
|
$network = $r['network'];
|
||||||
$rel = $r[0]['rel'];
|
$rel = $r['rel'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sparkle) {
|
if ($sparkle) {
|
||||||
|
@ -1036,7 +1035,7 @@ function item_photo_menu($item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $o;
|
return $o;
|
||||||
}}
|
}
|
||||||
|
|
||||||
if (! function_exists('builtin_activity_puller')) {
|
if (! function_exists('builtin_activity_puller')) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -509,6 +509,22 @@ class dba {
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert parameter array to an universal form
|
||||||
|
* @param array $args Parameter array
|
||||||
|
* @return array universalized parameter array
|
||||||
|
*/
|
||||||
|
private static function getParam($args) {
|
||||||
|
unset($args[0]);
|
||||||
|
|
||||||
|
// When the second function parameter is an array then use this as the parameter array
|
||||||
|
if ((count($args) > 0) && (is_array($args[1]))) {
|
||||||
|
return $args[1];
|
||||||
|
} else {
|
||||||
|
return $args;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Executes a prepared statement that returns data
|
* @brief Executes a prepared statement that returns data
|
||||||
* @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
|
* @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
|
||||||
|
@ -520,15 +536,7 @@ class dba {
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
$args = func_get_args();
|
$params = self::getParam(func_get_args());
|
||||||
unset($args[0]);
|
|
||||||
|
|
||||||
// When the second function parameter is an array then use this as the parameter array
|
|
||||||
if ((count($args) > 0) && (is_array($args[1]))) {
|
|
||||||
$params = $args[1];
|
|
||||||
} else {
|
|
||||||
$params = $args;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Renumber the array keys to be sure that they fit
|
// Renumber the array keys to be sure that they fit
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
@ -560,10 +568,10 @@ class dba {
|
||||||
self::$dbo->affected_rows = 0;
|
self::$dbo->affected_rows = 0;
|
||||||
|
|
||||||
// We have to make some things different if this function is called from "e"
|
// We have to make some things different if this function is called from "e"
|
||||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
||||||
|
|
||||||
if (isset($trace[2])) {
|
if (isset($trace[1])) {
|
||||||
$called_from = $trace[2];
|
$called_from = $trace[1];
|
||||||
} else {
|
} else {
|
||||||
// We use just something that is defined to avoid warnings
|
// We use just something that is defined to avoid warnings
|
||||||
$called_from = $trace[0];
|
$called_from = $trace[0];
|
||||||
|
@ -719,13 +727,13 @@ class dba {
|
||||||
|
|
||||||
$stamp = microtime(true);
|
$stamp = microtime(true);
|
||||||
|
|
||||||
$args = func_get_args();
|
$params = self::getParam(func_get_args());
|
||||||
|
|
||||||
// In a case of a deadlock we are repeating the query 20 times
|
// In a case of a deadlock we are repeating the query 20 times
|
||||||
$timeout = 20;
|
$timeout = 20;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$stmt = call_user_func_array('self::p', $args);
|
$stmt = self::p($sql, $params);
|
||||||
|
|
||||||
if (is_bool($stmt)) {
|
if (is_bool($stmt)) {
|
||||||
$retval = $stmt;
|
$retval = $stmt;
|
||||||
|
@ -744,15 +752,6 @@ class dba {
|
||||||
$error = self::$dbo->error;
|
$error = self::$dbo->error;
|
||||||
$errorno = self::$dbo->errorno;
|
$errorno = self::$dbo->errorno;
|
||||||
|
|
||||||
array_shift($args);
|
|
||||||
|
|
||||||
// When the second function parameter is an array then use this as the parameter array
|
|
||||||
if ((count($args) > 0) && (is_array($args[0]))) {
|
|
||||||
$params = $args[0];
|
|
||||||
} else {
|
|
||||||
$params = $args;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n".
|
logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n".
|
||||||
$a->callstack(8)."\n".self::replace_parameters($sql, $params));
|
$a->callstack(8)."\n".self::replace_parameters($sql, $params));
|
||||||
|
|
||||||
|
@ -772,9 +771,9 @@ class dba {
|
||||||
* @return boolean Are there rows for that query?
|
* @return boolean Are there rows for that query?
|
||||||
*/
|
*/
|
||||||
static public function exists($sql) {
|
static public function exists($sql) {
|
||||||
$args = func_get_args();
|
$params = self::getParam(func_get_args());
|
||||||
|
|
||||||
$stmt = call_user_func_array('self::p', $args);
|
$stmt = self::p($sql, $params);
|
||||||
|
|
||||||
if (is_bool($stmt)) {
|
if (is_bool($stmt)) {
|
||||||
$retval = $stmt;
|
$retval = $stmt;
|
||||||
|
@ -794,9 +793,9 @@ class dba {
|
||||||
* @return array first row of query
|
* @return array first row of query
|
||||||
*/
|
*/
|
||||||
static public function fetch_first($sql) {
|
static public function fetch_first($sql) {
|
||||||
$args = func_get_args();
|
$params = self::getParam(func_get_args());
|
||||||
|
|
||||||
$stmt = call_user_func_array('self::p', $args);
|
$stmt = self::p($sql, $params);
|
||||||
|
|
||||||
if (is_bool($stmt)) {
|
if (is_bool($stmt)) {
|
||||||
$retval = $stmt;
|
$retval = $stmt;
|
||||||
|
@ -891,12 +890,20 @@ class dba {
|
||||||
*
|
*
|
||||||
* @param string $table Table name
|
* @param string $table Table name
|
||||||
* @param array $param parameter array
|
* @param array $param parameter array
|
||||||
|
* @param bool $on_duplicate_update Do an update on a duplicate entry
|
||||||
*
|
*
|
||||||
* @return boolean was the insert successfull?
|
* @return boolean was the insert successfull?
|
||||||
*/
|
*/
|
||||||
static public function insert($table, $param) {
|
static public function insert($table, $param, $on_duplicate_update = false) {
|
||||||
$sql = "INSERT INTO `".self::$dbo->escape($table)."` (`".implode("`, `", array_keys($param))."`) VALUES (".
|
$sql = "INSERT INTO `".self::$dbo->escape($table)."` (`".implode("`, `", array_keys($param))."`) VALUES (".
|
||||||
substr(str_repeat("?, ", count($param)), 0, -2).");";
|
substr(str_repeat("?, ", count($param)), 0, -2).")";
|
||||||
|
|
||||||
|
if ($on_duplicate_update) {
|
||||||
|
$sql .= " ON DUPLICATE KEY UPDATE `".implode("` = ?, `", array_keys($param))."` = ?";
|
||||||
|
|
||||||
|
$values = array_values($param);
|
||||||
|
$param = array_merge_recursive($values, $values);
|
||||||
|
}
|
||||||
|
|
||||||
return self::e($sql, $param);
|
return self::e($sql, $param);
|
||||||
}
|
}
|
||||||
|
@ -1160,34 +1167,27 @@ class dba {
|
||||||
* @param string $table Table name
|
* @param string $table Table name
|
||||||
* @param array $fields contains the fields that are updated
|
* @param array $fields contains the fields that are updated
|
||||||
* @param array $condition condition array with the key values
|
* @param array $condition condition array with the key values
|
||||||
* @param array|boolean $old_fields array with the old field values that are about to be replaced
|
* @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate)
|
||||||
*
|
*
|
||||||
* @return boolean was the update successfull?
|
* @return boolean was the update successfull?
|
||||||
*/
|
*/
|
||||||
static public function update($table, $fields, $condition, $old_fields = array()) {
|
static public function update($table, $fields, $condition, $old_fields = array()) {
|
||||||
|
|
||||||
/** @todo We may use MySQL specific functions here:
|
|
||||||
* INSERT INTO `config` (`cat`, `k`, `v`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `v` = '%s'"
|
|
||||||
* But I think that it doesn't make sense here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
$table = self::$dbo->escape($table);
|
$table = self::$dbo->escape($table);
|
||||||
|
|
||||||
if (is_bool($old_fields)) {
|
if (is_bool($old_fields)) {
|
||||||
$sql = "SELECT * FROM `".$table."` WHERE `".
|
$sql = "SELECT * FROM `".$table."` WHERE `".
|
||||||
implode("` = ? AND `", array_keys($condition))."` = ? LIMIT 1";
|
implode("` = ? AND `", array_keys($condition))."` = ? LIMIT 1";
|
||||||
|
|
||||||
$params = array();
|
$params = array_values($condition);
|
||||||
foreach ($condition AS $value) {
|
|
||||||
$params[] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
$do_insert = $old_fields;
|
$do_insert = $old_fields;
|
||||||
|
|
||||||
$old_fields = self::fetch_first($sql, $params);
|
$old_fields = self::fetch_first($sql, $params);
|
||||||
if (is_bool($old_fields)) {
|
if (is_bool($old_fields)) {
|
||||||
if ($do_insert) {
|
if ($do_insert) {
|
||||||
return self::insert($table, $fields);
|
$values = array_merge($condition, $fields);
|
||||||
|
return self::insert($table, $values, $do_insert);
|
||||||
}
|
}
|
||||||
$old_fields = array();
|
$old_fields = array();
|
||||||
}
|
}
|
||||||
|
@ -1213,13 +1213,9 @@ class dba {
|
||||||
implode("` = ?, `", array_keys($fields))."` = ? WHERE `".
|
implode("` = ?, `", array_keys($fields))."` = ? WHERE `".
|
||||||
implode("` = ? AND `", array_keys($condition))."` = ?";
|
implode("` = ? AND `", array_keys($condition))."` = ?";
|
||||||
|
|
||||||
$params = array();
|
$params1 = array_values($fields);
|
||||||
foreach ($fields AS $value) {
|
$params2 = array_values($condition);
|
||||||
$params[] = $value;
|
$params = array_merge_recursive($params1, $params2);
|
||||||
}
|
|
||||||
foreach ($condition AS $value) {
|
|
||||||
$params[] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::e($sql, $params);
|
return self::e($sql, $params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -928,11 +928,9 @@ class Diaspora {
|
||||||
* Normally this should have handled by getting a request - but this could get lost
|
* Normally this should have handled by getting a request - but this could get lost
|
||||||
*/
|
*/
|
||||||
if ($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
|
if ($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
|
||||||
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
|
dba::update('contact', array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
|
||||||
intval(CONTACT_IS_FRIEND),
|
array('id' => $contact["id"], 'uid' => $contact["uid"]));
|
||||||
intval($contact["id"]),
|
|
||||||
intval($importer["uid"])
|
|
||||||
);
|
|
||||||
$contact["rel"] = CONTACT_IS_FRIEND;
|
$contact["rel"] = CONTACT_IS_FRIEND;
|
||||||
logger("defining user ".$contact["nick"]." as friend");
|
logger("defining user ".$contact["nick"]." as friend");
|
||||||
}
|
}
|
||||||
|
@ -1475,10 +1473,7 @@ class Diaspora {
|
||||||
|
|
||||||
// Formerly we stored the signed text, the signature and the author in different fields.
|
// Formerly we stored the signed text, the signature and the author in different fields.
|
||||||
// We now store the raw data so that we are more flexible.
|
// We now store the raw data so that we are more flexible.
|
||||||
q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
|
dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($data)));
|
||||||
intval($message_id),
|
|
||||||
dbesc(json_encode($data))
|
|
||||||
);
|
|
||||||
|
|
||||||
// notify others
|
// notify others
|
||||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
|
||||||
|
@ -1560,10 +1555,7 @@ class Diaspora {
|
||||||
|
|
||||||
dba::unlock();
|
dba::unlock();
|
||||||
|
|
||||||
q("UPDATE `conv` SET `updated` = '%s' WHERE `id` = %d",
|
dba::update('conv', array('updated' => datetime_convert()), array('id' => $conversation["id"]));
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($conversation["id"])
|
|
||||||
);
|
|
||||||
|
|
||||||
notification(array(
|
notification(array(
|
||||||
"type" => NOTIFY_MAIL,
|
"type" => NOTIFY_MAIL,
|
||||||
|
@ -1783,10 +1775,7 @@ class Diaspora {
|
||||||
|
|
||||||
// Formerly we stored the signed text, the signature and the author in different fields.
|
// Formerly we stored the signed text, the signature and the author in different fields.
|
||||||
// We now store the raw data so that we are more flexible.
|
// We now store the raw data so that we are more flexible.
|
||||||
q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
|
dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($data)));
|
||||||
intval($message_id),
|
|
||||||
dbesc(json_encode($data))
|
|
||||||
);
|
|
||||||
|
|
||||||
// notify others
|
// notify others
|
||||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
|
||||||
|
@ -1871,11 +1860,7 @@ class Diaspora {
|
||||||
|
|
||||||
dba::unlock();
|
dba::unlock();
|
||||||
|
|
||||||
q("UPDATE `conv` SET `updated` = '%s' WHERE `id` = %d",
|
dba::update('conv', array('updated' => datetime_convert()), array('id' => $conversation["id"]));
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($conversation["id"])
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2019,11 +2004,8 @@ class Diaspora {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if ($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
|
if ($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
|
||||||
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
|
dba::update('contact', array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
|
||||||
intval(CONTACT_IS_FRIEND),
|
array('id' => $contact["id"], 'uid' => $importer["uid"]));
|
||||||
intval($contact["id"]),
|
|
||||||
intval($importer["uid"])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
// send notification
|
// send notification
|
||||||
|
|
||||||
|
@ -2474,11 +2456,10 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently we don't have a central deletion function that we could use in this case. The function "item_drop" doesn't work for that case
|
// Currently we don't have a central deletion function that we could use in this case. The function "item_drop" doesn't work for that case
|
||||||
q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' WHERE `id` = %d",
|
dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
|
||||||
dbesc(datetime_convert()),
|
'edited' => datetime_convert(), 'changed' => datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
array('id' => $r[0]["id"]));
|
||||||
intval($r[0]["id"])
|
|
||||||
);
|
|
||||||
delete_thread($r[0]["id"], $r[0]["parent-uri"]);
|
delete_thread($r[0]["id"], $r[0]["parent-uri"]);
|
||||||
|
|
||||||
logger("Deleted target ".$target_guid." (".$r[0]["id"].") from user ".$importer["uid"]." parent: ".$p[0]["id"], LOGGER_DEBUG);
|
logger("Deleted target ".$target_guid." (".$r[0]["id"].") from user ".$importer["uid"]." parent: ".$p[0]["id"], LOGGER_DEBUG);
|
||||||
|
@ -3728,10 +3709,7 @@ class Diaspora {
|
||||||
* Now store the signature more flexible to dynamically support new fields.
|
* Now store the signature more flexible to dynamically support new fields.
|
||||||
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
|
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
|
||||||
*/
|
*/
|
||||||
q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
|
dba::insert('sign', array('iid' => $post_id, 'signed_text' => json_encode($message)));
|
||||||
intval($post_id),
|
|
||||||
dbesc(json_encode($message))
|
|
||||||
);
|
|
||||||
|
|
||||||
logger('Stored diaspora like signature');
|
logger('Stored diaspora like signature');
|
||||||
return true;
|
return true;
|
||||||
|
@ -3763,10 +3741,7 @@ class Diaspora {
|
||||||
* Now store the signature more flexible to dynamically support new fields.
|
* Now store the signature more flexible to dynamically support new fields.
|
||||||
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
|
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
|
||||||
*/
|
*/
|
||||||
q("INSERT INTO `sign` (`iid`, `signed_text`) VALUES (%d, '%s')",
|
dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($message)));
|
||||||
intval($message_id),
|
|
||||||
dbesc(json_encode($message))
|
|
||||||
);
|
|
||||||
|
|
||||||
logger('Stored diaspora comment signature');
|
logger('Stored diaspora comment signature');
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -13,11 +13,7 @@ function fcontact_store($url,$name,$photo) {
|
||||||
if (dbm::is_result($r))
|
if (dbm::is_result($r))
|
||||||
return $r[0]['id'];
|
return $r[0]['id'];
|
||||||
|
|
||||||
$r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ",
|
$r = dba::insert('fcontact', array('url' => $nurl, 'name' => $name, 'photo' => $photo));
|
||||||
dbesc($nurl),
|
|
||||||
dbesc($name),
|
|
||||||
dbesc($photo)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
|
$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
|
||||||
|
@ -31,11 +27,7 @@ function fcontact_store($url,$name,$photo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ffinder_store($uid,$cid,$fid) {
|
function ffinder_store($uid,$cid,$fid) {
|
||||||
$r = q("INSERT INTO `ffinder` ( `uid`, `cid`, `fid` ) VALUES ( %d, %d, %d ) ",
|
$r = dba::insert('ffinder', array('uid' => $uid, 'cid' => $cid, 'fid' => $fid));
|
||||||
intval($uid),
|
|
||||||
intval($cid),
|
|
||||||
intval($fid)
|
|
||||||
);
|
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,7 @@ function group_add($uid,$name) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$r = q("INSERT INTO `group` ( `uid`, `name` )
|
$r = dba::insert('group', array('uid' => $uid, 'name' => $name));
|
||||||
VALUES( %d, '%s' ) ",
|
|
||||||
intval($uid),
|
|
||||||
dbesc($name)
|
|
||||||
);
|
|
||||||
$ret = $r;
|
$ret = $r;
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
|
@ -144,12 +140,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
|
||||||
// we indicate success because the group member was in fact created
|
// we indicate success because the group member was in fact created
|
||||||
// -- It was just created at another time
|
// -- It was just created at another time
|
||||||
if (! dbm::is_result($r)) {
|
if (! dbm::is_result($r)) {
|
||||||
$r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
|
$r = dba::insert('group_member', array('uid' => $uid, 'gid' => $gid, 'contact-id' => $member));
|
||||||
VALUES( %d, %d, %d ) ",
|
|
||||||
intval($uid),
|
|
||||||
intval($gid),
|
|
||||||
intval($member)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,11 +138,10 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
|
||||||
if (remote_user() && count($_SESSION['remote'])) {
|
if (remote_user() && count($_SESSION['remote'])) {
|
||||||
foreach ($_SESSION['remote'] as $visitor) {
|
foreach ($_SESSION['remote'] as $visitor) {
|
||||||
if ($visitor['uid'] == $uid) {
|
if ($visitor['uid'] == $uid) {
|
||||||
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
|
$r = dba::select('contact', array('profile-id'), array('id' => $visitor['cid']), array('limit' => 1));
|
||||||
intval($visitor['cid'])
|
if (dbm::is_result($r)) {
|
||||||
);
|
$profile = $r['profile-id'];
|
||||||
if (dbm::is_result($r))
|
}
|
||||||
$profile = $r[0]['profile-id'];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,33 +151,32 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
|
||||||
|
|
||||||
if ($profile) {
|
if ($profile) {
|
||||||
$profile_int = intval($profile);
|
$profile_int = intval($profile);
|
||||||
$r = q("SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` AS `contact_photo`,
|
$r = dba::fetch_first("SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` AS `contact_photo`,
|
||||||
`contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
|
`contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
|
||||||
`profile`.`uid` AS `profile_uid`, `profile`.*,
|
`profile`.`uid` AS `profile_uid`, `profile`.*,
|
||||||
`contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.*
|
`contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.*
|
||||||
FROM `profile`
|
FROM `profile`
|
||||||
INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
|
INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
|
||||||
INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
||||||
WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d LIMIT 1",
|
WHERE `user`.`nickname` = ? AND `profile`.`id` = ? LIMIT 1",
|
||||||
dbesc($nickname),
|
$nickname,
|
||||||
intval($profile_int)
|
$profile_int
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!dbm::is_result($r)) {
|
if (!dbm::is_result($r)) {
|
||||||
$r = q("SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` as `contact_photo`,
|
$r = dba::fetch_first("SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` as `contact_photo`,
|
||||||
`contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
|
`contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
|
||||||
`profile`.`uid` AS `profile_uid`, `profile`.*,
|
`profile`.`uid` AS `profile_uid`, `profile`.*,
|
||||||
`contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.*
|
`contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.*
|
||||||
FROM `profile`
|
FROM `profile`
|
||||||
INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
|
INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
|
||||||
INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
||||||
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` LIMIT 1",
|
WHERE `user`.`nickname` = ? AND `profile`.`is-default` LIMIT 1",
|
||||||
dbesc($nickname)
|
$nickname
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r[0];
|
return $r;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -446,15 +446,6 @@ function store_conversation($arr) {
|
||||||
$conversation['source'] = $arr['source'];
|
$conversation['source'] = $arr['source'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Lock::set('store_conversation')) {
|
|
||||||
// When using semaphores, this case never can't happen
|
|
||||||
unset($arr['conversation-uri']);
|
|
||||||
unset($arr['conversation-href']);
|
|
||||||
unset($arr['protocol']);
|
|
||||||
unset($arr['source']);
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
$old_conv = dba::fetch_first("SELECT `item-uri`, `reply-to-uri`, `conversation-uri`, `conversation-href`, `protocol`, `source`
|
$old_conv = dba::fetch_first("SELECT `item-uri`, `reply-to-uri`, `conversation-uri`, `conversation-href`, `protocol`, `source`
|
||||||
FROM `conversation` WHERE `item-uri` = ?", $conversation['item-uri']);
|
FROM `conversation` WHERE `item-uri` = ?", $conversation['item-uri']);
|
||||||
if (dbm::is_result($old_conv)) {
|
if (dbm::is_result($old_conv)) {
|
||||||
|
@ -472,11 +463,10 @@ function store_conversation($arr) {
|
||||||
logger('Conversation: update for '.$conversation['item-uri'].' from '.$conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG);
|
logger('Conversation: update for '.$conversation['item-uri'].' from '.$conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!dba::insert('conversation', $conversation)) {
|
if (!dba::insert('conversation', $conversation, true)) {
|
||||||
logger('Conversation: insert for '.$conversation['item-uri'].' (protocol '.$conversation['protocol'].') failed', LOGGER_DEBUG);
|
logger('Conversation: insert for '.$conversation['item-uri'].' (protocol '.$conversation['protocol'].') failed', LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Lock::remove('store_conversation');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($arr['conversation-uri']);
|
unset($arr['conversation-uri']);
|
||||||
|
@ -854,7 +844,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
$self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
|
$self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
|
||||||
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
|
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
|
||||||
if ((normalise_link($arr['author-link']) == $self) || (normalise_link($arr['owner-link']) == $self)) {
|
if ((normalise_link($arr['author-link']) == $self) || (normalise_link($arr['owner-link']) == $self)) {
|
||||||
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id));
|
dba::update('thread', array('mention' => true), array('iid' => $parent_id));
|
||||||
logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
|
logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -918,7 +908,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
$arr["global"] = true;
|
$arr["global"] = true;
|
||||||
|
|
||||||
// Set the global flag on all items if this was a global item entry
|
// Set the global flag on all items if this was a global item entry
|
||||||
q("UPDATE `item` SET `global` = 1 WHERE `uri` = '%s'", dbesc($arr["uri"]));
|
dba::update('item', array('global' => true), array('uri' => $arr["uri"]));
|
||||||
} else {
|
} else {
|
||||||
$isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"]));
|
$isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"]));
|
||||||
|
|
||||||
|
@ -966,23 +956,10 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the unescaped version
|
|
||||||
$unescaped = $arr;
|
|
||||||
|
|
||||||
dbm::esc_array($arr, true);
|
|
||||||
|
|
||||||
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
|
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
|
||||||
|
|
||||||
dba::transaction();
|
dba::transaction();
|
||||||
|
$r = dba::insert('item', $arr);
|
||||||
$r = dbq("INSERT INTO `item` (`"
|
|
||||||
. implode("`, `", array_keys($arr))
|
|
||||||
. "`) VALUES ("
|
|
||||||
. implode(", ", array_values($arr))
|
|
||||||
. ")");
|
|
||||||
|
|
||||||
// And restore it
|
|
||||||
$arr = $unescaped;
|
|
||||||
|
|
||||||
// When the item was successfully stored we fetch the ID of the item.
|
// When the item was successfully stored we fetch the ID of the item.
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
|
@ -1062,10 +1039,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set parent id
|
// Set parent id
|
||||||
$r = q("UPDATE `item` SET `parent` = %d WHERE `id` = %d",
|
$r = dba::update('item', array('parent' => $parent_id), array('id' => $current_post));
|
||||||
intval($parent_id),
|
|
||||||
intval($current_post)
|
|
||||||
);
|
|
||||||
|
|
||||||
$arr['id'] = $current_post;
|
$arr['id'] = $current_post;
|
||||||
$arr['parent'] = $parent_id;
|
$arr['parent'] = $parent_id;
|
||||||
|
@ -1073,16 +1047,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
// update the commented timestamp on the parent
|
// update the commented timestamp on the parent
|
||||||
// Only update "commented" if it is really a comment
|
// Only update "commented" if it is really a comment
|
||||||
if (($arr['verb'] == ACTIVITY_POST) || !get_config("system", "like_no_comment")) {
|
if (($arr['verb'] == ACTIVITY_POST) || !get_config("system", "like_no_comment")) {
|
||||||
q("UPDATE `item` SET `commented` = '%s', `changed` = '%s' WHERE `id` = %d",
|
dba::update('item', array('commented' => datetime_convert(), 'changed' => datetime_convert()), array('id' => $parent_id));
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($parent_id)
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
q("UPDATE `item` SET `changed` = '%s' WHERE `id` = %d",
|
dba::update('item', array('changed' => datetime_convert()), array('id' => $parent_id));
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($parent_id)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dsprsig) {
|
if ($dsprsig) {
|
||||||
|
@ -1096,12 +1063,8 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG);
|
logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
q("INSERT INTO `sign` (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
|
dba::insert('sign', array('iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
|
||||||
intval($current_post),
|
'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer));
|
||||||
dbesc($dsprsig->signed_text),
|
|
||||||
dbesc($dsprsig->signature),
|
|
||||||
dbesc($dsprsig->signer)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$deleted = tag_deliver($arr['uid'], $current_post);
|
$deleted = tag_deliver($arr['uid'], $current_post);
|
||||||
|
@ -1189,26 +1152,17 @@ function item_set_last_item($arr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
q("UPDATE `contact` SET `success_update` = '%s', `last-item` = '%s' WHERE `id` = %d",
|
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
|
||||||
dbesc($arr['received']),
|
array('id' => $arr['contact-id']));
|
||||||
dbesc($arr['received']),
|
|
||||||
intval($arr['contact-id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
// Now do the same for the system wide contacts with uid=0
|
// Now do the same for the system wide contacts with uid=0
|
||||||
if (!$arr['private']) {
|
if (!$arr['private']) {
|
||||||
q("UPDATE `contact` SET `success_update` = '%s', `last-item` = '%s' WHERE `id` = %d",
|
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
|
||||||
dbesc($arr['received']),
|
array('id' => $arr['owner-id']));
|
||||||
dbesc($arr['received']),
|
|
||||||
intval($arr['owner-id'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($arr['owner-id'] != $arr['author-id']) {
|
if ($arr['owner-id'] != $arr['author-id']) {
|
||||||
q("UPDATE `contact` SET `success_update` = '%s', `last-item` = '%s' WHERE `id` = %d",
|
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
|
||||||
dbesc($arr['received']),
|
array('id' => $arr['author-id']));
|
||||||
dbesc($arr['received']),
|
|
||||||
intval($arr['author-id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1514,7 +1468,7 @@ function tgroup_check($uid, $item) {
|
||||||
*
|
*
|
||||||
* @todo fix type-hints (both array)
|
* @todo fix type-hints (both array)
|
||||||
*/
|
*/
|
||||||
function edited_timestamp_is_newer ($existing, $update) {
|
function edited_timestamp_is_newer($existing, $update) {
|
||||||
if (!x($existing, 'edited') || !$existing['edited']) {
|
if (!x($existing, 'edited') || !$existing['edited']) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1687,11 +1641,8 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
|
||||||
if (is_array($contact)) {
|
if (is_array($contact)) {
|
||||||
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
|
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
|
||||||
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||||
$r = q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
|
$r = dba::update('contact', array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
|
||||||
intval(CONTACT_IS_FRIEND),
|
array('id' => $contact['id'], 'uid' => $importer['uid']));
|
||||||
intval($contact['id']),
|
|
||||||
intval($importer['uid'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
// send email notification to owner?
|
// send email notification to owner?
|
||||||
} else {
|
} else {
|
||||||
|
@ -1731,13 +1682,9 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
|
||||||
$hash = random_string();
|
$hash = random_string();
|
||||||
|
|
||||||
if (is_array($contact_record)) {
|
if (is_array($contact_record)) {
|
||||||
$ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `hash`, `datetime`)
|
dba::insert('intro', array('uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
|
||||||
VALUES ( %d, %d, 0, 0, '%s', '%s' )",
|
'blocked' => false, 'knowyou' => false,
|
||||||
intval($importer['uid']),
|
'hash' => $hash, 'datetime' => datetime_convert()));
|
||||||
intval($contact_record['id']),
|
|
||||||
dbesc($hash),
|
|
||||||
dbesc(datetime_convert())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$def_gid = get_default_group($importer['uid'], $contact_record["network"]);
|
$def_gid = get_default_group($importer['uid'], $contact_record["network"]);
|
||||||
|
@ -1778,10 +1725,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
|
||||||
function lose_follower($importer, $contact, array $datarray = array(), $item = "") {
|
function lose_follower($importer, $contact, array $datarray = array(), $item = "") {
|
||||||
|
|
||||||
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
|
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
|
||||||
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
|
dba::update('contact', array('rel' => CONTACT_IS_SHARING), array('id' => $contact['id']));
|
||||||
intval(CONTACT_IS_SHARING),
|
|
||||||
intval($contact['id'])
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
contact_remove($contact['id']);
|
contact_remove($contact['id']);
|
||||||
}
|
}
|
||||||
|
@ -1790,10 +1734,7 @@ function lose_follower($importer, $contact, array $datarray = array(), $item = "
|
||||||
function lose_sharer($importer, $contact, array $datarray = array(), $item = "") {
|
function lose_sharer($importer, $contact, array $datarray = array(), $item = "") {
|
||||||
|
|
||||||
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||||
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
|
dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id']));
|
||||||
intval(CONTACT_IS_FOLLOWER),
|
|
||||||
intval($contact['id'])
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
contact_remove($contact['id']);
|
contact_remove($contact['id']);
|
||||||
}
|
}
|
||||||
|
@ -1828,10 +1769,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
|
||||||
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
|
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
|
||||||
|
|
||||||
if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
|
if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
|
||||||
$r = q("UPDATE `contact` SET `hub-verify` = '%s' WHERE `id` = %d",
|
$r = dba::update('contact', array('hub-verify' => $verify_token), array('id' => $contact['id']));
|
||||||
dbesc($verify_token),
|
|
||||||
intval($contact['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
post_url($url, $params);
|
post_url($url, $params);
|
||||||
|
@ -2199,13 +2137,12 @@ function drop_item($id, $interactive = true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('delete item: ' . $item['id'], LOGGER_DEBUG);
|
logger('delete item: ' . $item['id'], LOGGER_DEBUG);
|
||||||
// delete the item
|
|
||||||
|
|
||||||
$r = q("UPDATE `item` SET `deleted` = 1, `title` = '', `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d",
|
// delete the item
|
||||||
dbesc(datetime_convert()),
|
$r = dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
|
||||||
dbesc(datetime_convert()),
|
'edited' => datetime_convert(), 'changed' => datetime_convert()),
|
||||||
intval($item['id'])
|
array('id' => $item['id']));
|
||||||
);
|
|
||||||
create_tags_from_item($item['id']);
|
create_tags_from_item($item['id']);
|
||||||
create_files_from_item($item['id']);
|
create_files_from_item($item['id']);
|
||||||
delete_thread($item['id'], $item['parent-uri']);
|
delete_thread($item['id'], $item['parent-uri']);
|
||||||
|
@ -2288,33 +2225,26 @@ function drop_item($id, $interactive = true) {
|
||||||
|
|
||||||
// If it's the parent of a comment thread, kill all the kids
|
// If it's the parent of a comment thread, kill all the kids
|
||||||
if ($item['uri'] == $item['parent-uri']) {
|
if ($item['uri'] == $item['parent-uri']) {
|
||||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = ''
|
$r = dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
|
||||||
WHERE `parent-uri` = '%s' AND `uid` = %d ",
|
'edited' => datetime_convert(), 'changed' => datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid']));
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc($item['parent-uri']),
|
|
||||||
intval($item['uid'])
|
|
||||||
);
|
|
||||||
create_tags_from_itemuri($item['parent-uri'], $item['uid']);
|
create_tags_from_itemuri($item['parent-uri'], $item['uid']);
|
||||||
create_files_from_itemuri($item['parent-uri'], $item['uid']);
|
create_files_from_itemuri($item['parent-uri'], $item['uid']);
|
||||||
delete_thread_uri($item['parent-uri'], $item['uid']);
|
delete_thread_uri($item['parent-uri'], $item['uid']);
|
||||||
// ignore the result
|
// ignore the result
|
||||||
} else {
|
} else {
|
||||||
// ensure that last-child is set in case the comment that had it just got wiped.
|
// ensure that last-child is set in case the comment that had it just got wiped.
|
||||||
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
|
dba::update('item', array('last-child' => false, 'changed' => datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid']));
|
||||||
dbesc($item['parent-uri']),
|
|
||||||
intval($item['uid'])
|
|
||||||
);
|
|
||||||
// who is the last child now?
|
// who is the last child now?
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1",
|
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1",
|
||||||
dbesc($item['parent-uri']),
|
dbesc($item['parent-uri']),
|
||||||
intval($item['uid'])
|
intval($item['uid'])
|
||||||
);
|
);
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
|
dba::update('item', array('last-child' => true), array('id' => $r[0]['id']));
|
||||||
intval($r[0]['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,11 +82,8 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
|
||||||
} else { //save in cache
|
} else { //save in cache
|
||||||
$j = json_decode($txt);
|
$j = json_decode($txt);
|
||||||
if ($j->type != "error") {
|
if ($j->type != "error") {
|
||||||
q("INSERT INTO `oembed` (`url`, `content`, `created`) VALUES ('%s', '%s', '%s')
|
dba::insert('oembed', array('url' => normalise_link($embedurl),
|
||||||
ON DUPLICATE KEY UPDATE `content` = '%s', `created` = '%s'",
|
'content' => $txt, 'created' => datetime_convert()), true);
|
||||||
dbesc(normalise_link($embedurl)),
|
|
||||||
dbesc($txt), dbesc(datetime_convert()),
|
|
||||||
dbesc($txt), dbesc(datetime_convert()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::set($a->videowidth.$embedurl, $txt, CACHE_DAY);
|
Cache::set($a->videowidth.$embedurl, $txt, CACHE_DAY);
|
||||||
|
|
|
@ -46,22 +46,17 @@ function install_plugin($plugin) {
|
||||||
$func = $plugin . '_install';
|
$func = $plugin . '_install';
|
||||||
$func();
|
$func();
|
||||||
|
|
||||||
$plugin_admin = (function_exists($plugin."_plugin_admin")?1:0);
|
$plugin_admin = (function_exists($plugin."_plugin_admin") ? 1 : 0);
|
||||||
|
|
||||||
$r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ",
|
dba::insert('addon', array('name' => $plugin, 'installed' => true,
|
||||||
dbesc($plugin),
|
'timestamp' => $t, 'plugin_admin' => $plugin_admin));
|
||||||
intval($t),
|
|
||||||
$plugin_admin
|
|
||||||
);
|
|
||||||
|
|
||||||
// we can add the following with the previous SQL
|
// we can add the following with the previous SQL
|
||||||
// once most site tables have been updated.
|
// once most site tables have been updated.
|
||||||
// This way the system won't fall over dead during the update.
|
// This way the system won't fall over dead during the update.
|
||||||
|
|
||||||
if (file_exists('addon/' . $plugin . '/.hidden')) {
|
if (file_exists('addon/' . $plugin . '/.hidden')) {
|
||||||
q("UPDATE `addon` SET `hidden` = 1 WHERE `name` = '%s'",
|
dba::update('addon', array('hidden' => true), array('name' => $plugin));
|
||||||
dbesc($plugin)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -109,10 +104,7 @@ function reload_plugins() {
|
||||||
$func = $pl . '_install';
|
$func = $pl . '_install';
|
||||||
$func();
|
$func();
|
||||||
}
|
}
|
||||||
q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d",
|
dba::update('addon', array('timestamp' => $t), array('id' => $i['id']));
|
||||||
intval($t),
|
|
||||||
intval($i['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,12 +146,8 @@ function register_hook($hook,$file,$function,$priority=0) {
|
||||||
if (dbm::is_result($r))
|
if (dbm::is_result($r))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' ) ",
|
$r = dba::insert('hook', array('hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority));
|
||||||
dbesc($hook),
|
|
||||||
dbesc($file),
|
|
||||||
dbesc($function),
|
|
||||||
dbesc($priority)
|
|
||||||
);
|
|
||||||
return $r;
|
return $r;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -183,20 +171,19 @@ function unregister_hook($hook,$file,$function) {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
if (! function_exists('load_hooks')) {
|
|
||||||
function load_hooks() {
|
function load_hooks() {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$a->hooks = array();
|
$a->hooks = array();
|
||||||
$r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
|
$r = dba::select('hook', array('hook', 'file', 'function'), array(), array('order' => array('priority' => 'desc', 'file')));
|
||||||
|
|
||||||
if (dbm::is_result($r)) {
|
while ($rr = dba::fetch($r)) {
|
||||||
foreach ($r as $rr) {
|
if (! array_key_exists($rr['hook'],$a->hooks)) {
|
||||||
if (! array_key_exists($rr['hook'],$a->hooks))
|
|
||||||
$a->hooks[$rr['hook']] = array();
|
$a->hooks[$rr['hook']] = array();
|
||||||
|
}
|
||||||
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
|
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
|
||||||
}
|
}
|
||||||
}
|
dba::close($r);
|
||||||
}}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calls a hook.
|
* @brief Calls a hook.
|
||||||
|
|
|
@ -423,9 +423,7 @@ function display_content(App $a, $update = 0) {
|
||||||
intval($r[0]['parent']));
|
intval($r[0]['parent']));
|
||||||
|
|
||||||
if ($unseen) {
|
if ($unseen) {
|
||||||
q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d AND `unseen`",
|
dba::update('item', array('unseen' => false), array('parent' => $r[0]['parent'], 'unseen' => true));
|
||||||
intval($r[0]['parent'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -794,18 +794,12 @@ function network_content(App $a, $update = 0) {
|
||||||
|
|
||||||
|
|
||||||
if (!$group && !$cid && !$star) {
|
if (!$group && !$cid && !$star) {
|
||||||
|
$unseen = dba::select('item', array('id'), array('unseen' => true, 'uid' => local_user()), array('limit' => 1));
|
||||||
$unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `uid` = %d LIMIT 1",
|
|
||||||
intval(local_user()));
|
|
||||||
|
|
||||||
if (dbm::is_result($unseen)) {
|
if (dbm::is_result($unseen)) {
|
||||||
$r = q("UPDATE `item` SET `unseen` = 0
|
$r = dba::update('item', array('unseen' => false), array('uid' => local_user(), 'unseen' => true));
|
||||||
WHERE `unseen` = 1 AND `uid` = %d",
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} elseif ($update_unseen) {
|
} elseif ($update_unseen) {
|
||||||
|
|
||||||
$unseen = q("SELECT `id` FROM `item` ".$update_unseen. " LIMIT 1");
|
$unseen = q("SELECT `id` FROM `item` ".$update_unseen. " LIMIT 1");
|
||||||
|
|
||||||
if (dbm::is_result($unseen)) {
|
if (dbm::is_result($unseen)) {
|
||||||
|
|
11
src/App.php
11
src/App.php
|
@ -6,6 +6,7 @@ use Friendica\Core\Config;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
|
||||||
use Cache;
|
use Cache;
|
||||||
|
use dba;
|
||||||
use dbm;
|
use dbm;
|
||||||
|
|
||||||
use Detection\MobileDetect;
|
use Detection\MobileDetect;
|
||||||
|
@ -712,20 +713,20 @@ class App {
|
||||||
|
|
||||||
$this->remove_inactive_processes();
|
$this->remove_inactive_processes();
|
||||||
|
|
||||||
q('START TRANSACTION');
|
dba::transaction();
|
||||||
|
|
||||||
$r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
|
$r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
|
||||||
if (!dbm::is_result($r)) {
|
if (!dbm::is_result($r)) {
|
||||||
q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')", intval(getmypid()), dbesc($command), dbesc(datetime_convert()));
|
dba::insert('process', array('pid' => getmypid(), 'command' => $command, 'created' => datetime_convert()));
|
||||||
}
|
}
|
||||||
q('COMMIT');
|
dba::commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Remove inactive processes
|
* @brief Remove inactive processes
|
||||||
*/
|
*/
|
||||||
function remove_inactive_processes() {
|
function remove_inactive_processes() {
|
||||||
q('START TRANSACTION');
|
dba::transaction();
|
||||||
|
|
||||||
$r = q('SELECT `pid` FROM `process`');
|
$r = q('SELECT `pid` FROM `process`');
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
|
@ -735,7 +736,7 @@ class App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
q('COMMIT');
|
dba::commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Friendica\Core;
|
namespace Friendica\Core;
|
||||||
|
|
||||||
|
use dba;
|
||||||
use dbm;
|
use dbm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,9 +46,8 @@ class Config {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s'", dbesc($family));
|
$r = dba::select('config', array('v', 'k'), array('cat' => $family));
|
||||||
if (dbm::is_result($r)) {
|
while ($rr = dba::fetch($r)) {
|
||||||
foreach ($r as $rr) {
|
|
||||||
$k = $rr['k'];
|
$k = $rr['k'];
|
||||||
if ($family === 'config') {
|
if ($family === 'config') {
|
||||||
$a->config[$k] = $rr['v'];
|
$a->config[$k] = $rr['v'];
|
||||||
|
@ -57,7 +57,7 @@ class Config {
|
||||||
self::$in_db[$family][$k] = true;
|
self::$in_db[$family][$k] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
dba::close($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,13 +98,10 @@ class Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
|
$ret = dba::select('config', array('v'), array('cat' => $family, 'k' => $key), array('limit' => 1));
|
||||||
dbesc($family),
|
|
||||||
dbesc($key)
|
|
||||||
);
|
|
||||||
if (dbm::is_result($ret)) {
|
if (dbm::is_result($ret)) {
|
||||||
// manage array value
|
// manage array value
|
||||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v']) ? unserialize($ret[0]['v']) : $ret[0]['v']);
|
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
|
||||||
|
|
||||||
// Assign the value from the database to the cache
|
// Assign the value from the database to the cache
|
||||||
self::$cache[$family][$key] = $val;
|
self::$cache[$family][$key] = $val;
|
||||||
|
@ -167,20 +164,8 @@ class Config {
|
||||||
// manage array value
|
// manage array value
|
||||||
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
||||||
|
|
||||||
if (is_null($stored) || !self::$in_db[$family][$key]) {
|
dba::update('config', array('v' => $dbvalue), array('cat' => $family, 'k' => $key), true);
|
||||||
$ret = q("INSERT INTO `config` (`cat`, `k`, `v`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `v` = '%s'",
|
|
||||||
dbesc($family),
|
|
||||||
dbesc($key),
|
|
||||||
dbesc($dbvalue),
|
|
||||||
dbesc($dbvalue)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s'",
|
|
||||||
dbesc($dbvalue),
|
|
||||||
dbesc($family),
|
|
||||||
dbesc($key)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
self::$in_db[$family][$key] = true;
|
self::$in_db[$family][$key] = true;
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -206,10 +191,8 @@ class Config {
|
||||||
unset(self::$cache[$family][$key]);
|
unset(self::$cache[$family][$key]);
|
||||||
unset(self::$in_db[$family][$key]);
|
unset(self::$in_db[$family][$key]);
|
||||||
}
|
}
|
||||||
$ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
|
|
||||||
dbesc($family),
|
$ret = dba::delete('config', array('cat' => $family, 'k' => $key));
|
||||||
dbesc($key)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Friendica\Core;
|
namespace Friendica\Core;
|
||||||
|
|
||||||
|
use dba;
|
||||||
use dbm;
|
use dbm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,16 +35,15 @@ class PConfig {
|
||||||
*/
|
*/
|
||||||
public static function load($uid, $family) {
|
public static function load($uid, $family) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d ORDER BY `cat`, `k`, `id`",
|
|
||||||
dbesc($family),
|
$r = dba::select('pconfig', array('v', 'k'), array('cat' => $family, 'uid' => $uid));
|
||||||
intval($uid)
|
|
||||||
);
|
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $rr) {
|
while ($rr = dba::fetch($r)) {
|
||||||
$k = $rr['k'];
|
$k = $rr['k'];
|
||||||
$a->config[$uid][$family][$k] = $rr['v'];
|
$a->config[$uid][$family][$k] = $rr['v'];
|
||||||
self::$in_db[$uid][$family][$k] = true;
|
self::$in_db[$uid][$family][$k] = true;
|
||||||
}
|
}
|
||||||
|
dba::close($r);
|
||||||
} else if ($family != 'config') {
|
} else if ($family != 'config') {
|
||||||
// Negative caching
|
// Negative caching
|
||||||
$a->config[$uid][$family] = "!<unset>!";
|
$a->config[$uid][$family] = "!<unset>!";
|
||||||
|
@ -89,14 +89,9 @@ class PConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1",
|
$ret = dba::select('pconfig', array('v'), array('uid' => $uid, 'cat' => $family, 'k' => $key), array('limit' => 1));
|
||||||
intval($uid),
|
if (dbm::is_result($ret)) {
|
||||||
dbesc($family),
|
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
|
||||||
dbesc($key)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (count($ret)) {
|
|
||||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
|
|
||||||
$a->config[$uid][$family][$key] = $val;
|
$a->config[$uid][$family][$key] = $val;
|
||||||
self::$in_db[$uid][$family][$key] = true;
|
self::$in_db[$uid][$family][$key] = true;
|
||||||
|
|
||||||
|
@ -147,22 +142,7 @@ class PConfig {
|
||||||
// manage array value
|
// manage array value
|
||||||
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
||||||
|
|
||||||
if (is_null($stored) || !self::$in_db[$uid][$family][$key]) {
|
dba::update('pconfig', array('v' => $dbvalue), array('uid' => $uid, 'cat' => $family, 'k' => $key), true);
|
||||||
$ret = q("INSERT INTO `pconfig` (`uid`, `cat`, `k`, `v`) VALUES (%d, '%s', '%s', '%s') ON DUPLICATE KEY UPDATE `v` = '%s'",
|
|
||||||
intval($uid),
|
|
||||||
dbesc($family),
|
|
||||||
dbesc($key),
|
|
||||||
dbesc($dbvalue),
|
|
||||||
dbesc($dbvalue)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s'",
|
|
||||||
dbesc($dbvalue),
|
|
||||||
intval($uid),
|
|
||||||
dbesc($family),
|
|
||||||
dbesc($key)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
self::$in_db[$uid][$family][$key] = true;
|
self::$in_db[$uid][$family][$key] = true;
|
||||||
|
@ -193,11 +173,7 @@ class PConfig {
|
||||||
unset(self::$in_db[$uid][$family][$key]);
|
unset(self::$in_db[$uid][$family][$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s'",
|
$ret = dba::delete('pconfig', array('uid' => $uid, 'cat' => $family, 'k' => $key));
|
||||||
intval($uid),
|
|
||||||
dbesc($family),
|
|
||||||
dbesc($key)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace Friendica;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
use xml;
|
use xml;
|
||||||
|
use dba;
|
||||||
|
|
||||||
use DomXPath;
|
use DomXPath;
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
|
@ -66,11 +67,9 @@ class ParseUrl {
|
||||||
|
|
||||||
$data = self::getSiteinfo($url, $no_guessing, $do_oembed);
|
$data = self::getSiteinfo($url, $no_guessing, $do_oembed);
|
||||||
|
|
||||||
q("INSERT INTO `parsed_url` (`url`, `guessing`, `oembed`, `content`, `created`) VALUES ('%s', %d, %d, '%s', '%s')
|
dba::insert('parsed_url', array('url' => normalise_link($url), 'guessing' => !$no_guessing,
|
||||||
ON DUPLICATE KEY UPDATE `content` = '%s', `created` = '%s'",
|
'oembed' => $do_oembed, 'content' => serialize($data),
|
||||||
dbesc(normalise_link($url)), intval(!$no_guessing), intval($do_oembed),
|
'created' => datetime_convert()), true);
|
||||||
dbesc(serialize($data)), dbesc(datetime_convert()),
|
|
||||||
dbesc(serialize($data)), dbesc(datetime_convert()));
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue