mirror of
https://github.com/friendica/friendica
synced 2025-01-03 14:02:26 +00:00
Fix errors in Module namespace
This commit is contained in:
parent
650e65d4b4
commit
b35c45bf5a
9 changed files with 79 additions and 59 deletions
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
namespace Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
|
use Psr\Http\Message\UriInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Entity classes directly inheriting from this abstract class are meant to represent a single business entity.
|
* The Entity classes directly inheriting from this abstract class are meant to represent a single business entity.
|
||||||
|
@ -24,16 +26,32 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
* Since these objects aren't meant to be using any dependency, including logging, unit tests can and must be
|
* Since these objects aren't meant to be using any dependency, including logging, unit tests can and must be
|
||||||
* written for each and all of their methods
|
* written for each and all of their methods
|
||||||
*
|
*
|
||||||
* @property-read int $id
|
* @property-read int|null $id
|
||||||
* @property-read int $uid
|
* @property-read int $uid
|
||||||
* @property-read string $verb
|
* @property-read string $verb
|
||||||
* @property-read int $type
|
* @property-read int|string $type
|
||||||
* @property-read int $actorId
|
* @property-read int $actorId
|
||||||
* @property-read int $targetUriId
|
* @property-read int $targetUriId
|
||||||
* @property-read int $parentUriId
|
* @property-read int|null $parentUriId
|
||||||
* @property-read \DateTime $created
|
* @property-read \DateTime|string $created
|
||||||
* @property-read bool $seen
|
* @property-read bool $seen
|
||||||
* @property-read bool $dismissed
|
* @property-read bool $dismissed
|
||||||
|
* @property-read string $name
|
||||||
|
* @property-read UriInterface $url
|
||||||
|
* @property-read UriInterface $photo
|
||||||
|
* @property-read DateTime $date
|
||||||
|
* @property-read string|null $msg
|
||||||
|
* @property-read UriInterface $link
|
||||||
|
* @property-read int|null $itemId
|
||||||
|
* @property-read int|null $parent
|
||||||
|
* @property-read string|null $otype
|
||||||
|
* @property-read string|null $name_cache
|
||||||
|
* @property-read string|null $msg_cache
|
||||||
|
* @property-read int|null $uriId
|
||||||
|
* @property-read string $cookie_hash
|
||||||
|
* @property-read string $user_agent
|
||||||
|
* @property-read bool $trusted
|
||||||
|
* @property-read string|null $last_used
|
||||||
*/
|
*/
|
||||||
abstract class BaseEntity extends BaseDataTransferObject
|
abstract class BaseEntity extends BaseDataTransferObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Module\Admin;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
|
||||||
use Friendica\Core\Config\ValueObject\Cache;
|
use Friendica\Core\Config\ValueObject\Cache;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Update;
|
use Friendica\Core\Update;
|
||||||
|
@ -19,7 +18,6 @@ use Friendica\DI;
|
||||||
use Friendica\Core\Config\Factory\Config;
|
use Friendica\Core\Config\Factory\Config;
|
||||||
use Friendica\Module\BaseAdmin;
|
use Friendica\Module\BaseAdmin;
|
||||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||||
use Friendica\Network\HTTPException\ServiceUnavailableException;
|
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
|
@ -55,7 +53,7 @@ class Summary extends BaseAdmin
|
||||||
$table_definition_cache = DBA::getVariable('table_definition_cache');
|
$table_definition_cache = DBA::getVariable('table_definition_cache');
|
||||||
$table_open_cache = DBA::getVariable('table_open_cache');
|
$table_open_cache = DBA::getVariable('table_open_cache');
|
||||||
if (!empty($table_definition_cache) && !empty($table_open_cache)) {
|
if (!empty($table_definition_cache) && !empty($table_open_cache)) {
|
||||||
$suggested_definition_cache = min(400 + round($table_open_cache / 2, 1), 2000);
|
$suggested_definition_cache = min(400 + round((int) $table_open_cache / 2, 1), 2000);
|
||||||
if ($suggested_definition_cache > $table_definition_cache) {
|
if ($suggested_definition_cache > $table_definition_cache) {
|
||||||
$warningtext[] = DI::l10n()->t('Your table_definition_cache is too low (%d). This can lead to the database error "Prepared statement needs to be re-prepared". Please set it at least to %d. See <a href="%s">here</a> for more information.<br />', $table_definition_cache, $suggested_definition_cache, 'https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_definition_cache');
|
$warningtext[] = DI::l10n()->t('Your table_definition_cache is too low (%d). This can lead to the database error "Prepared statement needs to be re-prepared". Please set it at least to %d. See <a href="%s">here</a> for more information.<br />', $table_definition_cache, $suggested_definition_cache, 'https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_definition_cache');
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@ class BaseApi extends BaseModule
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set boundaries for the "link" header
|
* Set boundaries for the "link" header
|
||||||
* @param array $boundaries
|
*
|
||||||
* @param int|\DateTime $id
|
* @param int|\DateTime $id
|
||||||
*/
|
*/
|
||||||
protected static function setBoundaries($id)
|
protected static function setBoundaries($id)
|
||||||
|
|
|
@ -9,7 +9,8 @@ namespace Friendica\Module;
|
||||||
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
use Friendica\App;
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -30,7 +31,7 @@ class OpenSearch extends BaseModule
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $basePath;
|
private $basePath;
|
||||||
|
|
||||||
public function __construct(BasePath $basePath, IManageConfigValues $config, L10n $l10n, App\baseUrl $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
public function __construct(BasePath $basePath, IManageConfigValues $config, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||||
{
|
{
|
||||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
|
@ -43,8 +44,8 @@ class OpenSearch extends BaseModule
|
||||||
*/
|
*/
|
||||||
protected function rawContent(array $request = [])
|
protected function rawContent(array $request = [])
|
||||||
{
|
{
|
||||||
/** @var DOMDocument $xml */
|
XML::fromArray(
|
||||||
XML::fromArray([
|
[
|
||||||
'OpenSearchDescription' => [
|
'OpenSearchDescription' => [
|
||||||
'@attributes' => [
|
'@attributes' => [
|
||||||
'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
|
'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
|
||||||
|
@ -56,7 +57,10 @@ class OpenSearch extends BaseModule
|
||||||
'OutputEncoding' => 'UTF-8',
|
'OutputEncoding' => 'UTF-8',
|
||||||
'Developer' => 'Friendica Developer Team',
|
'Developer' => 'Friendica Developer Team',
|
||||||
],
|
],
|
||||||
], $xml);
|
],
|
||||||
|
/** @var DOMDocument $xml */
|
||||||
|
$xml
|
||||||
|
);
|
||||||
|
|
||||||
/** @var DOMElement $parent */
|
/** @var DOMElement $parent */
|
||||||
$parent = $xml->getElementsByTagName('OpenSearchDescription')[0];
|
$parent = $xml->getElementsByTagName('OpenSearchDescription')[0];
|
||||||
|
|
|
@ -69,7 +69,9 @@ class OpenID extends BaseModule
|
||||||
|
|
||||||
// Detect the server URL
|
// Detect the server URL
|
||||||
$open_id_obj = new LightOpenID(DI::baseUrl()->getHost());
|
$open_id_obj = new LightOpenID(DI::baseUrl()->getHost());
|
||||||
|
/** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
|
||||||
$open_id_obj->identity = $authId;
|
$open_id_obj->identity = $authId;
|
||||||
|
/** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
|
||||||
$session->set('openid_server', $open_id_obj->discover($open_id_obj->identity));
|
$session->set('openid_server', $open_id_obj->discover($open_id_obj->identity));
|
||||||
|
|
||||||
if (\Friendica\Module\Register::getPolicy() === \Friendica\Module\Register::CLOSED) {
|
if (\Friendica\Module\Register::getPolicy() === \Friendica\Module\Register::CLOSED) {
|
||||||
|
|
|
@ -7,12 +7,14 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Special;
|
namespace Friendica\Module\Special;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\Request;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session\Model\UserSession;
|
use Friendica\Core\Session\Model\UserSession;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
|
use Friendica\Network\HTTPException as NetworkHTTPException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +28,7 @@ class HTTPException
|
||||||
protected $l10n;
|
protected $l10n;
|
||||||
/** @var LoggerInterface */
|
/** @var LoggerInterface */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
/** @var App\Arguments */
|
/** @var Arguments */
|
||||||
protected $args;
|
protected $args;
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $isSiteAdmin;
|
protected $isSiteAdmin;
|
||||||
|
@ -35,7 +37,7 @@ class HTTPException
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $requestId;
|
protected $requestId;
|
||||||
|
|
||||||
public function __construct(L10n $l10n, LoggerInterface $logger, App\Arguments $args, UserSession $session, App\Request $request, array $server = [])
|
public function __construct(L10n $l10n, LoggerInterface $logger, Arguments $args, UserSession $session, Request $request, array $server = [])
|
||||||
{
|
{
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
@ -50,11 +52,9 @@ class HTTPException
|
||||||
*
|
*
|
||||||
* Fills in the blanks if title or descriptions aren't provided by the exception.
|
* Fills in the blanks if title or descriptions aren't provided by the exception.
|
||||||
*
|
*
|
||||||
* @param \Friendica\Network\HTTPException $e
|
|
||||||
*
|
|
||||||
* @return array ['$title' => ..., '$description' => ...]
|
* @return array ['$title' => ..., '$description' => ...]
|
||||||
*/
|
*/
|
||||||
private function getVars(\Friendica\Network\HTTPException $e)
|
private function getVars(NetworkHTTPException $e)
|
||||||
{
|
{
|
||||||
// Explanations are mostly taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
// Explanations are mostly taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
||||||
$vars = [
|
$vars = [
|
||||||
|
@ -76,11 +76,9 @@ class HTTPException
|
||||||
/**
|
/**
|
||||||
* Displays a bare message page with no theming at all.
|
* Displays a bare message page with no theming at all.
|
||||||
*
|
*
|
||||||
* @param \Friendica\Network\HTTPException $e
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function rawContent(\Friendica\Network\HTTPException $e)
|
public function rawContent(NetworkHTTPException $e)
|
||||||
{
|
{
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
||||||
|
@ -101,8 +99,9 @@ class HTTPException
|
||||||
|
|
||||||
// We can't use a constructor parameter for this response object because we
|
// We can't use a constructor parameter for this response object because we
|
||||||
// are in an Exception context where we don't want an existing Response.
|
// are in an Exception context where we don't want an existing Response.
|
||||||
|
$reason = ($e instanceof NetworkHTTPException) ? $e->getDescription() : $e->getMessage();
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
$response->setStatus($e->getCode(), $e->getDescription());
|
$response->setStatus($e->getCode(), $reason);
|
||||||
$response->addContent($content);
|
$response->addContent($content);
|
||||||
System::echoResponse($response->generate());
|
System::echoResponse($response->generate());
|
||||||
System::exit();
|
System::exit();
|
||||||
|
@ -111,12 +110,10 @@ class HTTPException
|
||||||
/**
|
/**
|
||||||
* Returns a content string that can be integrated in the current theme.
|
* Returns a content string that can be integrated in the current theme.
|
||||||
*
|
*
|
||||||
* @param \Friendica\Network\HTTPException $e
|
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function content(\Friendica\Network\HTTPException $e): string
|
public function content(NetworkHTTPException $e): string
|
||||||
{
|
{
|
||||||
if ($e->getCode() >= 400) {
|
if ($e->getCode() >= 400) {
|
||||||
$this->logger->debug('Exit with error',
|
$this->logger->debug('Exit with error',
|
||||||
|
|
|
@ -14,24 +14,24 @@ use Friendica\Core\Renderer;
|
||||||
use Psr\Http\Message\UriInterface;
|
use Psr\Http\Message\UriInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property-read $type
|
* @property-read string $type
|
||||||
* @property-read $name
|
* @property-read string $name
|
||||||
* @property-read $url
|
* @property-read UriInterface $url
|
||||||
* @property-read $photo
|
* @property-read UriInterface $photo
|
||||||
* @property-read $date
|
* @property-read DateTime $date
|
||||||
* @property-read $msg
|
* @property-read string|null $msg
|
||||||
* @property-read $uid
|
* @property-read int $uid
|
||||||
* @property-read $link
|
* @property-read UriInterface $link
|
||||||
* @property-read $itemId
|
* @property-read int|null $itemId
|
||||||
* @property-read $parent
|
* @property-read int|null $parent
|
||||||
* @property-read $seen
|
* @property-read bool $seen
|
||||||
* @property-read $verb
|
* @property-read string $verb
|
||||||
* @property-read $otype
|
* @property-read string|null $otype
|
||||||
* @property-read $name_cache
|
* @property-read string|null $name_cache
|
||||||
* @property-read $msg_cache
|
* @property-read string|null $msg_cache
|
||||||
* @property-read $uriId
|
* @property-read int|null $uriId
|
||||||
* @property-read $parentUriId
|
* @property-read int|null $parentUriId
|
||||||
* @property-read $id
|
* @property-read int|null $id
|
||||||
*
|
*
|
||||||
* @deprecated since 2022.05 Use \Friendica\Navigation\Notifications\Entity\Notification instead
|
* @deprecated since 2022.05 Use \Friendica\Navigation\Notifications\Entity\Notification instead
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -220,6 +220,7 @@ class Authentication
|
||||||
// Otherwise it's probably an openid.
|
// Otherwise it's probably an openid.
|
||||||
try {
|
try {
|
||||||
$openid = new LightOpenID($this->baseUrl->getHost());
|
$openid = new LightOpenID($this->baseUrl->getHost());
|
||||||
|
/** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
|
||||||
$openid->identity = $openid_url;
|
$openid->identity = $openid_url;
|
||||||
$this->session->set('openid', $openid_url);
|
$this->session->set('openid', $openid_url);
|
||||||
$this->session->set('remember', $remember);
|
$this->session->set('remember', $remember);
|
||||||
|
|
|
@ -14,12 +14,12 @@ use Friendica\Util\DateTimeFormat;
|
||||||
* Class TrustedBrowser
|
* Class TrustedBrowser
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @property-read $cookie_hash
|
* @property-read string $cookie_hash
|
||||||
* @property-read $uid
|
* @property-read int $uid
|
||||||
* @property-read $user_agent
|
* @property-read string $user_agent
|
||||||
* @property-read $trusted
|
* @property-read bool $trusted
|
||||||
* @property-read $created
|
* @property-read string $created
|
||||||
* @property-read $last_used
|
* @property-read string|null $last_used
|
||||||
* @package Friendica\Model\TwoFactor
|
* @package Friendica\Model\TwoFactor
|
||||||
*/
|
*/
|
||||||
class TrustedBrowser extends BaseEntity
|
class TrustedBrowser extends BaseEntity
|
||||||
|
|
Loading…
Reference in a new issue