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

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