Merge pull request #8034 from MrPetovan/bug/fatal-errors

Update missing references to DI
This commit is contained in:
Hypolite Petovan 2019-12-29 22:29:29 -05:00 committed by GitHub
commit 6546e99e9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 19 deletions

View file

@ -19,9 +19,7 @@ use Friendica\DI;
use Friendica\Model\Event; use Friendica\Model\Event;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;

View file

@ -178,7 +178,7 @@ function message_content(App $a)
DI::baseUrl()->redirect('message'); DI::baseUrl()->redirect('message');
} }
DI::baseUrl()->redirectinternalRedirect('message/' . $conversation['id'] ); DI::baseUrl()->redirect('message/' . $conversation['id'] );
} else { } else {
$r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]), intval($a->argv[2]),

View file

@ -4,6 +4,7 @@ use Friendica\App;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
use Friendica\Util\Strings; use Friendica\Util\Strings;

View file

@ -137,9 +137,9 @@ function redir_magic($a, $cid, $url)
// Shouldn't happen under normal conditions // Shouldn't happen under normal conditions
notice(L10n::t('Contact not found.')); notice(L10n::t('Contact not found.'));
if (!empty($url)) { if (!empty($url)) {
$a->redirect($url); System::externalRedirect($url);
} else { } else {
$a->internalRedirect(); DI::baseUrl()->redirect();
} }
} else { } else {
$contact_url = $contact['url']; $contact_url = $contact['url'];
@ -151,7 +151,7 @@ function redir_magic($a, $cid, $url)
// We don't use magic auth when there is no visitor, we are on the same system or we visit our own stuff // We don't use magic auth when there is no visitor, we are on the same system or we visit our own stuff
if (empty($visitor) || Strings::compareLink($basepath, System::baseUrl()) || Strings::compareLink($contact_url, $visitor)) { if (empty($visitor) || Strings::compareLink($basepath, System::baseUrl()) || Strings::compareLink($contact_url, $visitor)) {
Logger::info('Redirecting without magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]); Logger::info('Redirecting without magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]);
$a->redirect($target_url); System::externalRedirect($target_url);
} }
// Test for magic auth on the target system // Test for magic auth on the target system
@ -161,7 +161,7 @@ function redir_magic($a, $cid, $url)
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url); $target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
Logger::info('Redirecting with magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]); Logger::info('Redirecting with magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]);
$a->redirect($target_url); System::externalRedirect($target_url);
} else { } else {
Logger::info('No magic for contact', ['contact' => $contact_url]); Logger::info('No magic for contact', ['contact' => $contact_url]);
} }

View file

@ -7,6 +7,7 @@ use Friendica\Api\Mastodon\Account;
use Friendica\Api\Mastodon\Stats; use Friendica\Api\Mastodon\Stats;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\APContact; use Friendica\Model\APContact;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\Register; use Friendica\Module\Register;
@ -53,18 +54,19 @@ class Instance
* @return Instance * @return Instance
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function get(App $app) { public static function get()
{
$register_policy = intval(Config::get('config', 'register_policy')); $register_policy = intval(Config::get('config', 'register_policy'));
$instance = new Instance(); $instance = new Instance();
$instance->uri = $app->getBaseURL(); $instance->uri = DI::baseUrl()->get();
$instance->title = Config::get('config', 'sitename'); $instance->title = Config::get('config', 'sitename');
$instance->description = Config::get('config', 'info'); $instance->description = Config::get('config', 'info');
$instance->email = Config::get('config', 'admin_email'); $instance->email = Config::get('config', 'admin_email');
$instance->version = FRIENDICA_VERSION; $instance->version = FRIENDICA_VERSION;
$instance->urls = []; // Not supported $instance->urls = []; // Not supported
$instance->stats = Stats::get(); $instance->stats = Stats::get();
$instance->thumbnail = $app->getBaseURL() . (Config::get('system', 'shortcut_icon') ?? 'images/friendica-32.png'); $instance->thumbnail = DI::baseUrl()->get() . (Config::get('system', 'shortcut_icon') ?? 'images/friendica-32.png');
$instance->languages = [Config::get('system', 'language')]; $instance->languages = [Config::get('system', 'language')];
$instance->max_toot_chars = (int)Config::get('config', 'api_import_size', Config::get('config', 'max_import_size')); $instance->max_toot_chars = (int)Config::get('config', 'api_import_size', Config::get('config', 'max_import_size'));
$instance->registrations = ($register_policy != Register::CLOSED); $instance->registrations = ($register_policy != Register::CLOSED);

View file

@ -102,7 +102,7 @@ class Authentication
$user['password'] ?? '', $user['password'] ?? '',
$user['prvkey'] ?? '')) { $user['prvkey'] ?? '')) {
$this->logger->notice("Hash doesn't fit.", ['user' => $data->uid]); $this->logger->notice("Hash doesn't fit.", ['user' => $data->uid]);
$this->session->delete(); $this->session->clear();
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }
@ -137,7 +137,7 @@ class Authentication
'addr' => $this->session->get('addr'), 'addr' => $this->session->get('addr'),
'remote_addr' => $_SERVER['REMOTE_ADDR']] 'remote_addr' => $_SERVER['REMOTE_ADDR']]
); );
$this->session->delete(); $this->session->clear();
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }
@ -153,7 +153,7 @@ class Authentication
] ]
); );
if (!$this->dba->isResult($user)) { if (!$this->dba->isResult($user)) {
$this->session->delete(); $this->session->clear();
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }

View file

@ -30,7 +30,6 @@ class SessionFactory
* @param App\Mode $mode * @param App\Mode $mode
* @param App\BaseURL $baseURL * @param App\BaseURL $baseURL
* @param IConfiguration $config * @param IConfiguration $config
* @param Cookie $cookie
* @param Database $dba * @param Database $dba
* @param ICache $cache * @param ICache $cache
* @param LoggerInterface $logger * @param LoggerInterface $logger

View file

@ -12,6 +12,7 @@ use Friendica\Core\Config;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Module\Register; use Friendica\Module\Register;
use Friendica\Network\CurlResult;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -448,11 +449,12 @@ class GServer
/** /**
* Detect server type by using the nodeinfo data * Detect server type by using the nodeinfo data
* *
* @param string $url address of the server * @param string $url address of the server
* @param CurlResult $curlResult
* @return array Server data * @return array Server data
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function fetchNodeinfo(string $url, $curlResult) private static function fetchNodeinfo(string $url, CurlResult $curlResult)
{ {
$nodeinfo = json_decode($curlResult->getBody(), true); $nodeinfo = json_decode($curlResult->getBody(), true);

View file

@ -17,6 +17,6 @@ class Instance extends Api
*/ */
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
System::jsonExit(InstanceEntity::get(self::getApp())); System::jsonExit(InstanceEntity::get());
} }
} }

View file

@ -16,7 +16,7 @@ class HoverCard extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if ((local_user()) && ($parameters['action'] ?? '') === 'view') { if ((local_user()) && ($parameters['action'] ?? '') === 'view') {
// A logged in user views a profile of a user // A logged in user views a profile of a user

View file

@ -52,7 +52,7 @@ class OpenID extends BaseModule
// successful OpenID login // successful OpenID login
$session->remove('openid'); $session->remove('openid');
DI::auth()->setForUser(self::getApp(), $user, true, true); DI::auth()->setForUser(DI::app(), $user, true, true);
// just in case there was no return url set // just in case there was no return url set
// and we fell through // and we fell through