mirror of
https://github.com/friendica/friendica
synced 2025-04-29 14:24:22 +02:00
Remove unused code
- Remove commented code - Remove unused/immediately overwritten variables - Remove extraneous parameters - Remove unreachable code - Remove duplicate array keys
This commit is contained in:
parent
0c4f8277e6
commit
4a95ca280d
42 changed files with 43 additions and 218 deletions
|
@ -477,8 +477,6 @@ class Processor
|
|||
return;
|
||||
}
|
||||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
|
||||
$cid = Contact::getIdForURL($activity['actor'], $uid);
|
||||
if (empty($cid)) {
|
||||
Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG);
|
||||
|
@ -513,8 +511,6 @@ class Processor
|
|||
return;
|
||||
}
|
||||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
|
||||
$cid = Contact::getIdForURL($activity['actor'], $uid);
|
||||
if (empty($cid)) {
|
||||
Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG);
|
||||
|
|
|
@ -379,15 +379,15 @@ class Receiver
|
|||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||
ActivityPub\Processor::updateItem($object_data);
|
||||
} elseif (in_array($object_data['object_type'], self::ACCOUNT_TYPES)) {
|
||||
ActivityPub\Processor::updatePerson($object_data, $body);
|
||||
ActivityPub\Processor::updatePerson($object_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'as:Delete':
|
||||
if ($object_data['object_type'] == 'as:Tombstone') {
|
||||
ActivityPub\Processor::deleteItem($object_data, $body);
|
||||
ActivityPub\Processor::deleteItem($object_data);
|
||||
} elseif (in_array($object_data['object_type'], self::ACCOUNT_TYPES)) {
|
||||
ActivityPub\Processor::deletePerson($object_data, $body);
|
||||
ActivityPub\Processor::deletePerson($object_data);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -354,8 +354,6 @@ class Transmitter
|
|||
} else {
|
||||
$receiver_list = Item::enumeratePermissions($item);
|
||||
|
||||
$mentioned = [];
|
||||
|
||||
foreach ($terms as $term) {
|
||||
$cid = Contact::getIdForURL($term['url'], $item['uid']);
|
||||
if (!empty($cid) && in_array($cid, $receiver_list)) {
|
||||
|
|
|
@ -181,24 +181,19 @@ class DFRN
|
|||
|
||||
$owner = $r[0];
|
||||
$owner_id = $owner['uid'];
|
||||
$owner_nick = $owner['nickname'];
|
||||
|
||||
$sql_post_table = "";
|
||||
|
||||
if (! $public_feed) {
|
||||
$sql_extra = '';
|
||||
switch ($direction) {
|
||||
case (-1):
|
||||
$sql_extra = sprintf(" AND `issued-id` = '%s' ", DBA::escape($dfrn_id));
|
||||
$my_id = $dfrn_id;
|
||||
break;
|
||||
case 0:
|
||||
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
|
||||
$my_id = '1:' . $dfrn_id;
|
||||
break;
|
||||
case 1:
|
||||
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
|
||||
$my_id = '0:' . $dfrn_id;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
@ -244,7 +239,6 @@ class DFRN
|
|||
intval(TERM_CATEGORY),
|
||||
intval($owner_id)
|
||||
);
|
||||
//$sql_extra .= FileTag::fileQuery('item',$category,'category');
|
||||
}
|
||||
|
||||
if ($public_feed && ! $converse) {
|
||||
|
@ -1179,8 +1173,6 @@ class DFRN
|
|||
*/
|
||||
public static function deliver($owner, $contact, $atom, $dissolve = false, $legacy_transport = false)
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
// At first try the Diaspora transport layer
|
||||
if (!$dissolve && !$legacy_transport) {
|
||||
$curlResult = self::transmit($owner, $contact, $atom);
|
||||
|
@ -1205,7 +1197,6 @@ class DFRN
|
|||
Logger::log("Local rino version: ". $rino, Logger::DEBUG);
|
||||
|
||||
$ssl_val = intval(Config::get('system', 'ssl_policy'));
|
||||
$ssl_policy = '';
|
||||
|
||||
switch ($ssl_val) {
|
||||
case SSL_POLICY_FULL:
|
||||
|
@ -1442,8 +1433,6 @@ class DFRN
|
|||
*/
|
||||
public static function transmit($owner, $contact, $atom, $public_batch = false)
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
if (!$public_batch) {
|
||||
if (empty($contact['addr'])) {
|
||||
Logger::log('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.');
|
||||
|
@ -1708,7 +1697,6 @@ class DFRN
|
|||
|
||||
if (strtotime($value) < time()) {
|
||||
$value = str_replace($bdyear, $bdyear + 1, $value);
|
||||
$bdyear = $bdyear + 1;
|
||||
}
|
||||
|
||||
$poco["bd"] = $value;
|
||||
|
@ -1920,8 +1908,6 @@ class DFRN
|
|||
*/
|
||||
private static function processSuggestion($xpath, $suggestion, $importer)
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
Logger::log("Processing suggestions");
|
||||
|
||||
/// @TODO Rewrite this to one statement
|
||||
|
@ -1995,7 +1981,7 @@ class DFRN
|
|||
|
||||
$hash = Strings::getRandomHex();
|
||||
|
||||
$r = q(
|
||||
q(
|
||||
"INSERT INTO `intro` (`uid`, `fid`, `contact-id`, `note`, `hash`, `datetime`, `blocked`)
|
||||
VALUES(%d, %d, %d, '%s', '%s', '%s', %d)",
|
||||
intval($suggest["uid"]),
|
||||
|
@ -2408,8 +2394,6 @@ class DFRN
|
|||
$item["plink"] = $href;
|
||||
break;
|
||||
case "enclosure":
|
||||
$enclosure = $href;
|
||||
|
||||
if (!empty($item["attach"])) {
|
||||
$item["attach"] .= ",";
|
||||
} else {
|
||||
|
@ -2596,8 +2580,6 @@ class DFRN
|
|||
}
|
||||
}
|
||||
|
||||
$enclosure = "";
|
||||
|
||||
$links = $xpath->query("atom:link", $entry);
|
||||
if ($links) {
|
||||
self::parseLinks($links, $item);
|
||||
|
@ -2713,8 +2695,6 @@ class DFRN
|
|||
|
||||
if (in_array($entrytype, [DFRN::REPLY, DFRN::REPLY_RC])) {
|
||||
$posted_id = Item::insert($item);
|
||||
$parent = 0;
|
||||
|
||||
if ($posted_id) {
|
||||
Logger::log("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, Logger::DEBUG);
|
||||
|
||||
|
|
|
@ -748,8 +748,6 @@ class Diaspora
|
|||
Logger::log("Unknown message type ".$type);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2354,8 +2352,6 @@ class Diaspora
|
|||
*/
|
||||
private static function receiveRequestMakeFriend(array $importer, array $contact)
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
if ($contact["rel"] == Contact::SHARING) {
|
||||
DBA::update(
|
||||
'contact',
|
||||
|
@ -2415,7 +2411,7 @@ class Diaspora
|
|||
$user = DBA::selectFirst('user', [], ['uid' => $importer["uid"]]);
|
||||
if (DBA::isResult($user)) {
|
||||
Logger::log("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], Logger::DEBUG);
|
||||
$ret = self::sendShare($user, $contact);
|
||||
self::sendShare($user, $contact);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -2449,7 +2445,7 @@ class Diaspora
|
|||
|
||||
$batch = (($ret["batch"]) ? $ret["batch"] : implode("/", array_slice(explode("/", $ret["url"]), 0, 3))."/receive/public");
|
||||
|
||||
$r = q(
|
||||
q(
|
||||
"INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`nurl`,`batch`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
|
||||
VALUES (%d, '%s', '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d)",
|
||||
intval($importer["uid"]),
|
||||
|
@ -2489,7 +2485,7 @@ class Diaspora
|
|||
|
||||
$hash = Strings::getRandomHex().(string)time(); // Generate a confirm_key
|
||||
|
||||
$ret = q(
|
||||
q(
|
||||
"INSERT INTO `intro` (`uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
|
||||
VALUES (%d, %d, %d, %d, '%s', '%s', '%s')",
|
||||
intval($importer["uid"]),
|
||||
|
@ -2520,7 +2516,7 @@ class Diaspora
|
|||
$new_relation = Contact::FOLLOWER;
|
||||
}
|
||||
|
||||
$r = q(
|
||||
q(
|
||||
"UPDATE `contact` SET `rel` = %d,
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
|
@ -2538,7 +2534,7 @@ class Diaspora
|
|||
$user = DBA::selectFirst('user', [], ['uid' => $importer["uid"]]);
|
||||
if (DBA::isResult($user)) {
|
||||
Logger::log("Sending share message (Relation: ".$new_relation.") to author ".$author." - Contact: ".$contact_record["id"]." - User: ".$importer["uid"], Logger::DEBUG);
|
||||
$ret = self::sendShare($user, $contact_record);
|
||||
self::sendShare($user, $contact_record);
|
||||
|
||||
// Send the profile data, maybe it weren't transmitted before
|
||||
self::sendProfile($importer["uid"], [$contact_record]);
|
||||
|
@ -3127,8 +3123,6 @@ class Diaspora
|
|||
*/
|
||||
public static function transmit(array $owner, array $contact, $envelope, $public_batch, $queue_run = false, $guid = "", $no_queue = false)
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
$enabled = intval(Config::get("system", "diaspora_enabled"));
|
||||
if (!$enabled) {
|
||||
return 200;
|
||||
|
@ -3871,15 +3865,14 @@ class Diaspora
|
|||
// Remove the handle
|
||||
$handle = array_pop($signed_parts);
|
||||
|
||||
// Glue the parts together
|
||||
$text = implode(";", $signed_parts);
|
||||
|
||||
$message = ["author" => $handle,
|
||||
"guid" => $guid,
|
||||
"parent_guid" => $parent_guid,
|
||||
"text" => implode(";", $signed_parts),
|
||||
"author_signature" => $item['signature'],
|
||||
"parent_author_signature" => ""];
|
||||
$message = [
|
||||
"author" => $handle,
|
||||
"guid" => $guid,
|
||||
"parent_guid" => $parent_guid,
|
||||
"text" => implode(";", $signed_parts),
|
||||
"author_signature" => $item['signature'],
|
||||
"parent_author_signature" => ""
|
||||
];
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
@ -3996,14 +3989,6 @@ class Diaspora
|
|||
return;
|
||||
}
|
||||
|
||||
$conv = [
|
||||
"author" => $cnv["creator"],
|
||||
"guid" => $cnv["guid"],
|
||||
"subject" => $cnv["subject"],
|
||||
"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
|
||||
"participants" => $cnv["recips"]
|
||||
];
|
||||
|
||||
$body = BBCode::toMarkdown($item["body"]);
|
||||
$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
|
||||
|
||||
|
@ -4020,12 +4005,13 @@ class Diaspora
|
|||
$type = "message";
|
||||
} else {
|
||||
$message = [
|
||||
"author" => $cnv["creator"],
|
||||
"guid" => $cnv["guid"],
|
||||
"subject" => $cnv["subject"],
|
||||
"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
|
||||
"participants" => $cnv["recips"],
|
||||
"message" => $msg];
|
||||
"author" => $cnv["creator"],
|
||||
"guid" => $cnv["guid"],
|
||||
"subject" => $cnv["subject"],
|
||||
"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
|
||||
"participants" => $cnv["recips"],
|
||||
"message" => $msg
|
||||
];
|
||||
|
||||
$type = "conversation";
|
||||
}
|
||||
|
|
|
@ -178,8 +178,6 @@ class Email
|
|||
// $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple
|
||||
global $htmlmsg,$plainmsg,$charset,$attachments;
|
||||
|
||||
//echo $partno."\n";
|
||||
|
||||
// DECODE DATA
|
||||
$data = ($partno)
|
||||
? @imap_fetchbody($mbox, $uid, $partno, FT_UID|FT_PEEK)
|
||||
|
@ -247,9 +245,6 @@ class Email
|
|||
$x = "";
|
||||
foreach ($p->parts as $partno0 => $p2) {
|
||||
$x .= self::messageGetPart($mbox, $uid, $p2, $partno . '.' . ($partno0+1), $subtype); // 1.2, 1.2.1, etc.
|
||||
//if ($x) {
|
||||
// return $x;
|
||||
//}
|
||||
}
|
||||
return $x;
|
||||
}
|
||||
|
@ -559,26 +554,6 @@ class Email
|
|||
$nextline = ltrim(substr($nextline, 1));
|
||||
}
|
||||
|
||||
$firstword = strpos($nextline.' ', ' ');
|
||||
|
||||
$specialchars = ((substr(trim($nextline), 0, 1) == '-') ||
|
||||
(substr(trim($nextline), 0, 1) == '=') ||
|
||||
(substr(trim($nextline), 0, 1) == '*') ||
|
||||
(substr(trim($nextline), 0, 1) == '·') ||
|
||||
(substr(trim($nextline), 0, 4) == '[url') ||
|
||||
(substr(trim($nextline), 0, 5) == '[size') ||
|
||||
(substr(trim($nextline), 0, 7) == 'http://') ||
|
||||
(substr(trim($nextline), 0, 8) == 'https://'));
|
||||
|
||||
if (!$specialchars) {
|
||||
$specialchars = ((substr(rtrim($line), -1) == '-') ||
|
||||
(substr(rtrim($line), -1) == '=') ||
|
||||
(substr(rtrim($line), -1) == '*') ||
|
||||
(substr(rtrim($line), -1) == '·') ||
|
||||
(substr(rtrim($line), -6) == '[/url]') ||
|
||||
(substr(rtrim($line), -7) == '[/size]'));
|
||||
}
|
||||
|
||||
if (!empty($lines[$lineno])) {
|
||||
if (substr($lines[$lineno], -1) != ' ') {
|
||||
$lines[$lineno] .= ' ';
|
||||
|
@ -625,13 +600,11 @@ class Email
|
|||
}
|
||||
|
||||
$quotelevel = 0;
|
||||
$previousquote = 0;
|
||||
$arrbodyquoted = [];
|
||||
|
||||
for ($i = 0; $i < count($arrbody); $i++) {
|
||||
$previousquote = $quotelevel;
|
||||
$quotelevel = $arrlevel[$i];
|
||||
$currline = $arrbody[$i];
|
||||
|
||||
while ($previousquote < $quotelevel) {
|
||||
$quote = "[quote]";
|
||||
|
|
|
@ -318,7 +318,6 @@ class Feed {
|
|||
$href = "";
|
||||
$length = "";
|
||||
$type = "";
|
||||
$title = "";
|
||||
|
||||
foreach ($enclosure->attributes AS $attribute) {
|
||||
if (in_array($attribute->name, ["url", "href"])) {
|
||||
|
|
|
@ -398,8 +398,6 @@ class OStatus
|
|||
$authordata = $xpath->query('//author')->item(0);
|
||||
$author = self::fetchAuthor($xpath, $authordata, $importer, $contact, $stored);
|
||||
|
||||
$entry = $xpath->query('/atom:entry');
|
||||
|
||||
// Reverse the order of the entries
|
||||
$entrylist = [];
|
||||
|
||||
|
@ -528,7 +526,6 @@ class OStatus
|
|||
|
||||
if ($valid) {
|
||||
$default_contact = 0;
|
||||
$key = count(self::$itemlist);
|
||||
for ($key = count(self::$itemlist) - 1; $key >= 0; $key--) {
|
||||
if (empty(self::$itemlist[$key]['contact-id'])) {
|
||||
self::$itemlist[$key]['contact-id'] = $default_contact;
|
||||
|
@ -1191,7 +1188,6 @@ class OStatus
|
|||
} else {
|
||||
return "http://".$server[0]."/notice/".$conversation[1];
|
||||
}
|
||||
return $href;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1287,8 +1283,6 @@ class OStatus
|
|||
*/
|
||||
private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false)
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
$root = $doc->createElementNS(NAMESPACE_ATOM1, 'feed');
|
||||
$doc->appendChild($root);
|
||||
|
||||
|
@ -1699,7 +1693,7 @@ class OStatus
|
|||
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
|
||||
}
|
||||
|
||||
$title = self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
|
||||
$condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => false,
|
||||
'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
|
||||
|
@ -1764,7 +1758,7 @@ class OStatus
|
|||
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
|
||||
}
|
||||
|
||||
$title = self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
|
||||
$verb = NAMESPACE_ACTIVITY_SCHEMA."favorite";
|
||||
self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
|
||||
|
|
|
@ -63,8 +63,6 @@ class PortableContact
|
|||
*/
|
||||
public static function load($cid, $uid, $zcid, $url)
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
if ($cid) {
|
||||
if (!$url || !$uid) {
|
||||
$contact = DBA::selectFirst('contact', ['poco', 'uid'], ['id' => $cid]);
|
||||
|
@ -230,7 +228,6 @@ class PortableContact
|
|||
$friendica = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$1$2", $profile);
|
||||
if ($friendica != $profile) {
|
||||
$server_url = $friendica;
|
||||
$network = Protocol::DFRN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,7 +235,6 @@ class PortableContact
|
|||
$diaspora = preg_replace("=(https?://)(.*)/u/(.*)=ism", "$1$2", $profile);
|
||||
if ($diaspora != $profile) {
|
||||
$server_url = $diaspora;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +242,6 @@ class PortableContact
|
|||
$red = preg_replace("=(https?://)(.*)/channel/(.*)=ism", "$1$2", $profile);
|
||||
if ($red != $profile) {
|
||||
$server_url = $red;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,7 +250,6 @@ class PortableContact
|
|||
$mastodon = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
|
||||
if ($mastodon != $profile) {
|
||||
$server_url = $mastodon;
|
||||
$network = Protocol::OSTATUS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +258,6 @@ class PortableContact
|
|||
$ostatus = preg_replace("=(https?://)(.*)/user/(.*)=ism", "$1$2", $profile);
|
||||
if ($ostatus != $profile) {
|
||||
$server_url = $ostatus;
|
||||
$network = Protocol::OSTATUS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,7 +266,6 @@ class PortableContact
|
|||
$base = preg_replace("=(https?://)(.*?)/(.*)=ism", "$1$2", $profile);
|
||||
if ($base != $profile) {
|
||||
$server_url = $base;
|
||||
$network = Protocol::PHANTOM;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -609,8 +601,6 @@ class PortableContact
|
|||
*/
|
||||
private static function detectPocoData(array $data)
|
||||
{
|
||||
$server = false;
|
||||
|
||||
if (!isset($data['entry'])) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue