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:
Hypolite Petovan 2019-01-07 12:09:10 -05:00
parent 0c4f8277e6
commit 4a95ca280d
42 changed files with 43 additions and 218 deletions

View File

@ -370,8 +370,6 @@ class OEmbed
*/
private static function iframe($src, $width, $height)
{
$a = \get_app();
if (!$height || strstr($height, '%')) {
$height = '200';
}

View File

@ -1683,7 +1683,7 @@ class BBCode extends BaseObject
// Replace non graphical smilies for external posts
if ($simple_html) {
$text = Smilies::replace($text, false, true);
$text = Smilies::replace($text);
}
// Unhide all [noparse] contained bbtags unspacefying them

View File

@ -84,8 +84,6 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter
public function set($cat, $k, $value)
{
$a = self::getApp();
// We store our setting values in a string variable.
// So we have to do the conversion here so that the compare below works.
// The exception are array values.

View File

@ -73,7 +73,6 @@ HELP;
$this->out('Options: ' . var_export($this->options, true));
}
$showHelp = false;
$subHelp = false;
$command = null;
@ -83,7 +82,6 @@ HELP;
return 0;
} elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0
) {
$showHelp = true;
} elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {
$command = $this->getArgument(1);
$subHelp = true;

View File

@ -47,8 +47,6 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
$a = \get_app();
$pofile = realpath($this->getArgument(0));
if (!file_exists($pofile)) {
@ -106,7 +104,6 @@ HELP;
}
if ($inv) {
$inv = false;
$out .= '"' . $v . '"';
}
@ -179,7 +176,6 @@ HELP;
}
if ($inv) {
$inv = false;
$out .= '"' . $v . '"';
}

View File

@ -37,8 +37,6 @@ HELP;
protected function doExecute()
{
$a = \Friendica\BaseObject::getApp();
if ($this->getOption('v')) {
$this->out('Executable: ' . $this->executable);
$this->out('Class: ' . __CLASS__);

View File

@ -224,8 +224,6 @@ class Installer
*/
public function checkPHP($phppath = null, $required = false)
{
$passed = false;
$passed2 = false;
$passed3 = false;
if (!isset($phppath)) {
@ -394,7 +392,7 @@ class Installer
$help = '';
$status = true;
try {
$xml = new DOMDocument();
new DOMDocument();
} catch (Exception $e) {
$help = L10n::t('Error, XML PHP module required but not installed.');
$status = false;

View File

@ -229,7 +229,6 @@ class NotificationsManager extends BaseObject
*/
private function formatNotifs(array $notifs, $ident = "")
{
$notif = [];
$arr = [];
if (DBA::isResult($notifs)) {

View File

@ -37,7 +37,7 @@ class PConfig extends BaseObject
if ($a->getConfigValue('system', 'config_adapter') == 'preload') {
self::$adapter = new Config\PreloadPConfigAdapter($uid);
} else {
self::$adapter = new Config\JITPConfigAdapter($uid);
self::$adapter = new Config\JITPConfigAdapter();
}
}

View File

@ -59,7 +59,6 @@ class System extends BaseObject
array_shift($trace);
$callstack = [];
$counter = 0;
$previous = ['class' => '', 'function' => ''];
// The ignore list contains all functions that are only wrapper functions

View File

@ -1105,7 +1105,7 @@ class DBA
if ((count($conditions) == 1) && ($field == array_keys($conditions)[0])) {
foreach ($rel_def AS $rel_table => $rel_fields) {
foreach ($rel_fields AS $rel_field) {
$retval = self::delete($rel_table, [$rel_field => array_values($conditions)[0]], $options, $callstack);
self::delete($rel_table, [$rel_field => array_values($conditions)[0]], $options, $callstack);
}
}
// We quit when this key already exists in the callstack.
@ -1579,8 +1579,6 @@ class DBA
$ret = self::p("SHOW PROCESSLIST");
$data = self::toArray($ret);
$s = [];
$processes = 0;
$states = [];
foreach ($data as $process) {

View File

@ -885,8 +885,6 @@ class Contact extends BaseObject
*/
public static function getDetailsByAddr($addr, $uid = -1)
{
static $cache = [];
if ($addr == '') {
return [];
}
@ -942,14 +940,9 @@ class Contact extends BaseObject
*/
public static function photoMenu(array $contact, $uid = 0)
{
// @todo Unused, to be removed
$a = \get_app();
$contact_url = '';
$pm_url = '';
$status_link = '';
$photos_link = '';
$posts_link = '';
$contact_drop_link = '';
$poke_link = '';
@ -1219,7 +1212,6 @@ class Contact extends BaseObject
$contact_id = self::getIdForURL($data["alias"], $uid, true, $default, true);
}
$url = $data["url"];
if (!$contact_id) {
$fields = [
'uid' => $uid,

View File

@ -239,8 +239,6 @@ class Event extends BaseObject
*/
public static function store($arr)
{
$a = self::getApp();
$event = [];
$event['id'] = intval(defaults($arr, 'id' , 0));
$event['uid'] = intval(defaults($arr, 'uid' , 0));
@ -418,7 +416,6 @@ class Event extends BaseObject
"February" => L10n::t("February"),
"March" => L10n::t("March"),
"April" => L10n::t("April"),
"May" => L10n::t("May"),
"June" => L10n::t("June"),
"July" => L10n::t("July"),
"August" => L10n::t("August"),
@ -643,7 +640,7 @@ class Event extends BaseObject
*
* @todo Implement timezone support
*/
private static function formatListForExport(array $events, $format, $timezone)
private static function formatListForExport(array $events, $format)
{
if (!count($events)) {
return '';
@ -795,19 +792,14 @@ class Event extends BaseObject
{
$process = false;
$user = DBA::selectFirst('user', ['timezone'], ['uid' => $uid]);
if (DBA::isResult($user)) {
$timezone = $user['timezone'];
}
// Get all events which are owned by a uid (respects permissions).
$events = self::getListByUserId($uid);
// We have the events that are available for the requestor.
// Now format the output according to the requested format.
$res = self::formatListForExport($events, $format, $timezone);
$res = self::formatListForExport($events, $format);
// If there are results the precess was successfull.
// If there are results the precess was successful.
if (!empty($res)) {
$process = true;
}

View File

@ -528,8 +528,6 @@ class GContact
*/
public static function updateSuggestions()
{
$a = \get_app();
$done = [];
/// @TODO Check if it is really neccessary to poll the own server

View File

@ -316,8 +316,6 @@ class Group extends BaseObject
*/
public static function displayGroupSelection($uid, $gid = 0, $label = '')
{
$o = '';
$stmt = DBA::select('group', [], ['deleted' => 0, 'uid' => $uid], ['order' => ['name']]);
$display_groups = [

View File

@ -1236,12 +1236,16 @@ class Item extends BaseObject
// This function will finally cover most of the preparation functionality in mod/item.php
public static function prepare(&$item)
{
/*
* @TODO: Unused code triggering inspection errors
*
$data = BBCode::getAttachmentData($item['body']);
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $item['body'], $match, PREG_SET_ORDER) || isset($data["type"]))
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
$posttype = Item::PT_PAGE;
$objecttype = ACTIVITY_OBJ_BOOKMARK;
}
*/
}
public static function insert($item, $force_parent = false, $notify = false, $dontcache = false)
@ -3040,7 +3044,6 @@ class Item extends BaseObject
// Contact-id is the uid-dependant author contact
if (local_user() == $uid) {
$item_contact_id = $owner_self_contact['id'];
$item_contact = $owner_self_contact;
} else {
$item_contact_id = Contact::getIdForURL($author_contact['url'], $uid, true);
$item_contact = DBA::selectFirst('contact', [], ['id' => $item_contact_id]);
@ -3167,8 +3170,6 @@ class Item extends BaseObject
$item["mention"] = 1;
}
$sql = "";
$fields = [];
foreach ($item as $field => $data) {

View File

@ -172,7 +172,6 @@ class Photo extends BaseObject
*/
public static function getImageForPhoto(array $photo)
{
$data = "";
if ($photo["backend-class"] == "") {
// legacy data storage in "data" column
$i = self::selectFirst(["data"], ["id" => $photo["id"]]);
@ -268,7 +267,6 @@ class Photo extends BaseObject
// if is an existing photo, reuse same backend
$data = "";
$backend_ref = "";
$backend_class = "";
if (DBA::isResult($existing_photo)) {
$backend_ref = (string)$existing_photo["backend-ref"];
@ -276,6 +274,7 @@ class Photo extends BaseObject
} else {
$backend_class = StorageManager::getBackend();
}
if ($backend_class === "") {
$data = $Image->asString();
} else {

View File

@ -745,14 +745,8 @@ class Profile
public static function getAdvanced(App $a)
{
$o = '';
$uid = $a->profile['uid'];
$o .= Renderer::replaceMacros(
Renderer::getMarkupTemplate('section_title.tpl'),
['$title' => L10n::t('Profile')]
);
if ($a->profile['name']) {
$tpl = Renderer::getMarkupTemplate('profile_advanced.tpl');

View File

@ -60,7 +60,6 @@ class Filesystem implements IStorage
if (!mkdir($path, 0770, true)) {
Logger::log('Failed to create dirs ' . $path);
throw new StorageException(L10n::t('Filesystem storage failed to create "%s". Check you write permissions.', $path));
killme();
}
}
@ -100,7 +99,6 @@ class Filesystem implements IStorage
if ($r === FALSE) {
Logger::log('Failed to write data to ' . $file);
throw new StorageException(L10n::t('Filesystem storage failed to save data to "%s". Check your write permissions', $file));
killme();
}
return $ref;
}

View File

@ -438,7 +438,6 @@ class User
$return = ['user' => null, 'password' => ''];
$using_invites = Config::get('system', 'invitation_only');
$num_invites = Config::get('system', 'number_invites');
$invite_id = !empty($data['invite_id']) ? Strings::escapeTags(trim($data['invite_id'])) : '';
$username = !empty($data['username']) ? Strings::escapeTags(trim($data['username'])) : '';
@ -501,8 +500,6 @@ class User
$openid_url = '';
}
$err = '';
// collapse multiple spaces in name
$username = preg_replace('/ +/', ' ', $username);
@ -826,8 +823,6 @@ class User
return false;
}
$a = \get_app();
Logger::log('Removing user: ' . $uid);
$user = DBA::selectFirst('user', [], ['uid' => $uid]);

View File

@ -310,7 +310,7 @@ class Contact extends BaseModule
return;
}
$r = DBA::update('contact', $fields, ['id' => $contact_id, 'uid' => local_user()]);
DBA::update('contact', $fields, ['id' => $contact_id, 'uid' => local_user()]);
// Update the entry in the contact table
Model\Contact::updateAvatar($data['photo'], local_user(), $contact_id, true);
@ -470,7 +470,6 @@ class Contact extends BaseModule
$_SESSION['return_path'] = $a->query_string;
if (!empty($a->data['contact']) && is_array($a->data['contact'])) {
$contact_id = $a->data['contact']['id'];
$contact = $a->data['contact'];
$a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [
@ -632,7 +631,6 @@ class Contact extends BaseModule
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($contact['hidden'] == 1), L10n::t('Replies/likes to your public posts <strong>may</strong> still be visible')],
'$notify' => ['notify', L10n::t('Notification for new posts'), ($contact['notify_new_posts'] == 1), L10n::t('Send a notification of every new post of this contact')],
'$fetch_further_information' => $fetch_further_information,
'$ffi_keyword_blacklist' => $contact['ffi_keyword_blacklist'],
'$ffi_keyword_blacklist' => ['ffi_keyword_blacklist', L10n::t('Blacklisted keywords'), $contact['ffi_keyword_blacklist'], L10n::t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')],
'$photo' => $contact['photo'],
'$name' => $contact['name'],

View File

@ -101,13 +101,13 @@ class Proxy extends BaseModule
// If there is an error then return a blank image
if ((substr($fetchResult->getReturnCode(), 0, 1) == '4') || (!$img_str)) {
self::responseError($request);
self::responseError();
// stop.
}
$image = new Image($img_str, $mime);
if (!$image->isValid()) {
self::responseError($request);
self::responseError();
// stop.
}
@ -157,7 +157,6 @@ class Proxy extends BaseModule
private static function getRequestInfo()
{
$a = self::getApp();
$url = '';
$size = 1024;
$sizetype = '';

View File

@ -1302,7 +1302,6 @@ class Probe
$data["addr"] = str_replace('acct:', '', $webfinger["subject"]);
}
$pubkey = "";
if (is_array($webfinger["links"])) {
// The array is reversed to take into account the order of preference for same-rel links
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4

View File

@ -298,8 +298,6 @@ class Image
$width = $this->getWidth();
$height = $this->getHeight();
$dest_width = $dest_height = 0;
if ((! $width)|| (! $height)) {
return false;
}
@ -502,8 +500,6 @@ class Image
$width = $this->getWidth();
$height = $this->getHeight();
$dest_width = $dest_height = 0;
if ((!$width)|| (!$height)) {
return false;
}
@ -693,8 +689,6 @@ class Image
return $string;
}
$quality = false;
ob_start();
// Enable interlacing
@ -736,7 +730,6 @@ class Image
Logger::log('Image: guessType: '.$filename . ($fromcurl?' from curl headers':''), Logger::DEBUG);
$type = null;
if ($fromcurl) {
$a = \get_app();
$headers=[];
$h = explode("\n", $header);
foreach ($h as $l) {
@ -835,8 +828,6 @@ class Image
*/
public static function getScalingDimensions($width, $height, $max)
{
$dest_width = $dest_height = 0;
if ((!$width) || (!$height)) {
return false;
}
@ -967,8 +958,6 @@ class Image
$hash = Photo::newResource();
$smallest = 0;
// Pictures are always public by now
//$defperm = '<'.$default_cid.'>';
$defperm = "";

View File

@ -789,7 +789,7 @@ class Post extends BaseObject
}
if ($conv->isWritable() && $this->isWritable()) {
$qc = $qcomment = null;
$qcomment = null;
/*
* Hmmm, code depending on the presence of a particular addon?

View File

@ -178,9 +178,7 @@ class Thread extends BaseObject
*/
public function getTemplateData($conv_responses)
{
$a = self::getApp();
$result = [];
$i = 0;
foreach ($this->parents as $item) {
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {

View File

@ -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);

View File

@ -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;

View File

@ -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)) {

View File

@ -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);

View File

@ -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";
}

View File

@ -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]";

View File

@ -318,7 +318,6 @@ class Feed {
$href = "";
$length = "";
$type = "";
$title = "";
foreach ($enclosure->attributes AS $attribute) {
if (in_array($attribute->name, ["url", "href"])) {

View File

@ -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);

View File

@ -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;
}

View File

@ -92,8 +92,6 @@ class Network
*/
public static function curl($url, $binary = false, &$redirects = 0, $opts = [])
{
$ret = ['return_code' => 0, 'success' => false, 'header' => '', 'info' => '', 'body' => ''];
$stamp1 = microtime(true);
$a = \get_app();
@ -322,7 +320,6 @@ class Network
$s = @curl_exec($ch);
$base = $s;
$curl_info = curl_getinfo($ch);
$curlResponse = new CurlResult($url, $s, $curl_info, curl_errno($ch), curl_error($ch));

View File

@ -113,8 +113,6 @@ class ParseUrl
*/
public static function getSiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1)
{
$a = \get_app();
$siteinfo = [];
// Check if the URL does contain a scheme

View File

@ -287,9 +287,6 @@ class XML
//Initializations
$xml_array = [];
$parents = [];
$opened_tags = [];
$arr = [];
$current = &$xml_array; // Reference

View File

@ -143,13 +143,11 @@ class Cron
$manual_id = 0;
$generation = 0;
$force = false;
$restart = false;
if ($parameter == 'force') {
$force = true;
}
if ($parameter == 'restart') {
$restart = true;
$generation = intval($generation);
if (!$generation) {
exit();
@ -167,8 +165,6 @@ class Cron
Addon::reload();
$d = DateTimeFormat::utcNow();
// Only poll from those with suitable relationships,
// and which have a polling address and ignore Diaspora since
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.

View File

@ -60,8 +60,6 @@ class DBClean {
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function removeOrphans($stage) {
$count = 0;
// We split the deletion in many small tasks
$limit = Config::get('system', 'dbclean-expire-limit', 1000);

View File

@ -30,11 +30,7 @@ class OnePoll
Logger::log('Start for contact ' . $contact_id);
$manual_id = 0;
$generation = 0;
$hub_update = false;
$force = false;
$restart = false;
if ($command == "force") {
$force = true;
@ -45,7 +41,6 @@ class OnePoll
return;
}
$d = DateTimeFormat::utcNow();
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
if (!DBA::isResult($contact)) {
@ -580,7 +575,7 @@ class OnePoll
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
}
$stored_item = Item::insert($datarray);
Item::insert($datarray);
switch ($mailconf['action']) {
case 0:

View File

@ -26,8 +26,6 @@ class PubSubPublish
private static function publish($id)
{
$a = BaseObject::getApp();
$subscriber = DBA::selectFirst('push_subscriber', [], ['id' => $id]);
if (!DBA::isResult($subscriber)) {
return;
@ -58,8 +56,6 @@ class PubSubPublish
$postResult = Network::post($subscriber['callback_url'], $params, $headers);
$ret = $postResult->getReturnCode();
$condition = ['id' => $subscriber['id']];
if ($ret >= 200 && $ret <= 299) {
Logger::log('Successfully pushed to ' . $subscriber['callback_url']);