Merge pull request #8854 from MrPetovan/bug/notices

Address various notices again
This commit is contained in:
Michael Vogel 2020-07-09 21:45:27 +02:00 committed by GitHub
commit ced0effa2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 23 deletions

View File

@ -335,16 +335,16 @@ function api_call(App $a, App\Arguments $args = null)
if (!empty($info['auth']) && api_user() === false) { if (!empty($info['auth']) && api_user() === false) {
api_login($a); api_login($a);
Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username']]);
} }
Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username']]);
Logger::debug(API_LOG_PREFIX . 'parameters', ['module' => 'api', 'action' => 'call', 'parameters' => $_REQUEST]); Logger::debug(API_LOG_PREFIX . 'parameters', ['module' => 'api', 'action' => 'call', 'parameters' => $_REQUEST]);
$stamp = microtime(true); $stamp = microtime(true);
$return = call_user_func($info['func'], $type); $return = call_user_func($info['func'], $type);
$duration = floatval(microtime(true) - $stamp); $duration = floatval(microtime(true) - $stamp);
Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username'], 'duration' => round($duration, 2)]); Logger::info(API_LOG_PREFIX . 'duration {duration}', ['module' => 'api', 'action' => 'call', 'duration' => round($duration, 2)]);
DI::profiler()->saveLog(DI::logger(), API_LOG_PREFIX . 'performance'); DI::profiler()->saveLog(DI::logger(), API_LOG_PREFIX . 'performance');

View File

@ -37,17 +37,18 @@ use Friendica\Model\Event;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Module\BaseProfile; use Friendica\Module\BaseProfile;
use Friendica\Network\HTTPException;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
function cal_init(App $a) function cal_init(App $a)
{ {
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
} }
if ($a->argc < 2) { if ($a->argc < 2) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
} }
Nav::setSelected('events'); Nav::setSelected('events');
@ -55,7 +56,7 @@ function cal_init(App $a)
$nick = $a->argv[1]; $nick = $a->argv[1];
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]); $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
throw new \Friendica\Network\HTTPException\NotFoundException(); throw new HTTPException\NotFoundException();
} }
$a->data['user'] = $user; $a->data['user'] = $user;
@ -67,18 +68,22 @@ function cal_init(App $a)
return; return;
} }
$profile = Profile::getByNickname($nick, $a->profile_uid); $a->profile = Profile::getByNickname($nick, $a->profile_uid);
$account_type = Contact::getAccountType($profile); if (empty($a->profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$account_type = Contact::getAccountType($a->profile);
$tpl = Renderer::getMarkupTemplate('widget/vcard.tpl'); $tpl = Renderer::getMarkupTemplate('widget/vcard.tpl');
$vcard_widget = Renderer::replaceMacros($tpl, [ $vcard_widget = Renderer::replaceMacros($tpl, [
'$name' => $profile['name'], '$name' => $a->profile['name'],
'$photo' => $profile['photo'], '$photo' => $a->profile['photo'],
'$addr' => $profile['addr'] ?: '', '$addr' => $a->profile['addr'] ?: '',
'$account_type' => $account_type, '$account_type' => $account_type,
'$about' => BBCode::convert($profile['about']), '$about' => BBCode::convert($a->profile['about']),
]); ]);
$cal_widget = Widget\CalendarExport::getHTML(); $cal_widget = Widget\CalendarExport::getHTML();

View File

@ -778,7 +778,7 @@ function photos_post(App $a)
// Create item container // Create item container
$lat = $lon = null; $lat = $lon = null;
if ($exif && $exif['GPS'] && Feature::isEnabled($page_owner_uid, 'photo_location')) { if (!empty($exif['GPS']) && Feature::isEnabled($page_owner_uid, 'photo_location')) {
$lat = Photo::getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']); $lat = Photo::getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
$lon = Photo::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']); $lon = Photo::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
} }

View File

@ -276,7 +276,7 @@ class Page implements ArrayAccess
// If you're just visiting, let javascript take you home // If you're just visiting, let javascript take you home
if (!empty($_SESSION['visitor_home'])) { if (!empty($_SESSION['visitor_home'])) {
$homebase = $_SESSION['visitor_home']; $homebase = $_SESSION['visitor_home'];
} elseif (local_user()) { } elseif (!empty($app->user['nickname'])) {
$homebase = 'profile/' . $app->user['nickname']; $homebase = 'profile/' . $app->user['nickname'];
} }

View File

@ -96,11 +96,11 @@ abstract class BaseModule
* Functions used to protect against Cross-Site Request Forgery * Functions used to protect against Cross-Site Request Forgery
* The security token has to base on at least one value that an attacker can't know - here it's the session ID and the private key. * The security token has to base on at least one value that an attacker can't know - here it's the session ID and the private key.
* In this implementation, a security token is reusable (if the user submits a form, goes back and resubmits the form, maybe with small changes; * In this implementation, a security token is reusable (if the user submits a form, goes back and resubmits the form, maybe with small changes;
* or if the security token is used for ajax-calls that happen several times), but only valid for a certain amout of time (3hours). * or if the security token is used for ajax-calls that happen several times), but only valid for a certain amount of time (3hours).
* The "typename" seperates the security tokens of different types of forms. This could be relevant in the following case: * The "typename" separates the security tokens of different types of forms. This could be relevant in the following case:
* A security token is used to protekt a link from CSRF (e.g. the "delete this profile"-link). * A security token is used to protect a link from CSRF (e.g. the "delete this profile"-link).
* If the new page contains by any chance external elements, then the used security token is exposed by the referrer. * If the new page contains by any chance external elements, then the used security token is exposed by the referrer.
* Actually, important actions should not be triggered by Links / GET-Requests at all, but somethimes they still are, * Actually, important actions should not be triggered by Links / GET-Requests at all, but sometimes they still are,
* so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types). * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types).
*/ */
public static function getFormSecurityToken($typename = '') public static function getFormSecurityToken($typename = '')
@ -108,7 +108,7 @@ abstract class BaseModule
$a = DI::app(); $a = DI::app();
$timestamp = time(); $timestamp = time();
$sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename); $sec_hash = hash('whirlpool', ($a->user['guid'] ?? '') . ($a->user['prvkey'] ?? '') . session_id() . $timestamp . $typename);
return $timestamp . '.' . $sec_hash; return $timestamp . '.' . $sec_hash;
} }

View File

@ -75,7 +75,7 @@ class UserItem
private static function setNotificationForUser(array $item, int $uid) private static function setNotificationForUser(array $item, int $uid)
{ {
$thread = Item::selectFirstThreadForUser($uid, ['ignored'], ['iid' => $item['parent'], 'deleted' => false]); $thread = Item::selectFirstThreadForUser($uid, ['ignored'], ['iid' => $item['parent'], 'deleted' => false]);
if ($thread['ignored']) { if (!empty($thread['ignored'])) {
return; return;
} }

View File

@ -26,7 +26,7 @@ use Friendica\Core\Session;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPException\NotFoundException; use Friendica\Network\HTTPException;
/** /**
* Loads a profile for the HoverCard view * Loads a profile for the HoverCard view
@ -44,11 +44,15 @@ class HoverCard extends BaseModule
// Show the profile hovercard // Show the profile hovercard
$nickname = $parameters['profile']; $nickname = $parameters['profile'];
} else { } else {
throw new NotFoundException(DI::l10n()->t('No profile')); throw new HTTPException\NotFoundException(DI::l10n()->t('No profile'));
} }
Profile::load($a, $nickname); Profile::load($a, $nickname);
if (empty($a->profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$page = DI::page(); $page = DI::page();
if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) { if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {

View File

@ -224,7 +224,7 @@ function frio_remote_nav($a, &$nav)
// since $userinfo isn't available for the hook we write it to the nav array // since $userinfo isn't available for the hook we write it to the nav array
// this isn't optimal because the contact query will be done now twice // this isn't optimal because the contact query will be done now twice
if (local_user()) { if (local_user() && !empty($a->user['uid'])) {
// empty the server url for local user because we won't need it // empty the server url for local user because we won't need it
$server_url = ''; $server_url = '';
// user info // user info

View File

@ -27,7 +27,7 @@ function vier_init(App $a)
Renderer::setActiveTemplateEngine('smarty3'); Renderer::setActiveTemplateEngine('smarty3');
if (!empty($a->argv[0]) && ($a->argv[0] . ($a->argv[1] ?? '')) === ('profile' . $a->user['nickname']) || $a->argv[0] === 'network' && local_user()) { if (!empty($a->argv[0]) && ($a->argv[0] . ($a->argv[1] ?? '')) === ('profile' . ($a->user['nickname'] ?? '')) || $a->argv[0] === 'network' && local_user()) {
vier_community_info(); vier_community_info();
DI::page()['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n"; DI::page()['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";