Merge remote-tracking branch 'upstream/develop' into collapse
This commit is contained in:
commit
50746bad55
|
@ -84,7 +84,7 @@ class Addon
|
||||||
public static function getAdminList(): array
|
public static function getAdminList(): array
|
||||||
{
|
{
|
||||||
$addons_admin = [];
|
$addons_admin = [];
|
||||||
$addons = DI::config()->get('addons') ?? [];
|
$addons = array_filter(DI::config()->get('addons') ?? []);
|
||||||
|
|
||||||
ksort($addons);
|
ksort($addons);
|
||||||
foreach ($addons as $name => $data) {
|
foreach ($addons as $name => $data) {
|
||||||
|
@ -117,7 +117,7 @@ class Addon
|
||||||
*/
|
*/
|
||||||
public static function loadAddons()
|
public static function loadAddons()
|
||||||
{
|
{
|
||||||
self::$addons = array_keys(DI::config()->get('addons') ?? []);
|
self::$addons = array_keys(array_filter(DI::config()->get('addons') ?? []));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,7 +192,7 @@ class Addon
|
||||||
*/
|
*/
|
||||||
public static function reload()
|
public static function reload()
|
||||||
{
|
{
|
||||||
$addons = DI::config()->get('addons') ?? [];
|
$addons = array_filter(DI::config()->get('addons') ?? []);
|
||||||
|
|
||||||
foreach ($addons as $name => $data) {
|
foreach ($addons as $name => $data) {
|
||||||
$addonname = Strings::sanitizeFilePathItem(trim($name));
|
$addonname = Strings::sanitizeFilePathItem(trim($name));
|
||||||
|
@ -315,7 +315,7 @@ class Addon
|
||||||
public static function getVisibleList(): array
|
public static function getVisibleList(): array
|
||||||
{
|
{
|
||||||
$visible_addons = [];
|
$visible_addons = [];
|
||||||
$addons = DI::config()->get('addons') ?? [];
|
$addons = array_filter(DI::config()->get('addons') ?? []);
|
||||||
|
|
||||||
foreach ($addons as $name => $data) {
|
foreach ($addons as $name => $data) {
|
||||||
$visible_addons[] = $name;
|
$visible_addons[] = $name;
|
||||||
|
|
|
@ -177,7 +177,7 @@ class ConfigFileManager
|
||||||
{
|
{
|
||||||
$filename = $this->configDir . '/' . self::CONFIG_DATA_FILE;
|
$filename = $this->configDir . '/' . self::CONFIG_DATA_FILE;
|
||||||
|
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename) && (filesize($filename) > 0)) {
|
||||||
|
|
||||||
// The fallback empty return content
|
// The fallback empty return content
|
||||||
$content = '<?php return [];';
|
$content = '<?php return [];';
|
||||||
|
@ -188,10 +188,19 @@ class ConfigFileManager
|
||||||
*
|
*
|
||||||
* Any exclusive locking (LOCK_EX) would need to wait until all LOCK_SHs are unlocked
|
* Any exclusive locking (LOCK_EX) would need to wait until all LOCK_SHs are unlocked
|
||||||
*/
|
*/
|
||||||
$configStream = fopen($filename, 'r');
|
if (($configStream = @fopen($filename, 'r')) === false) {
|
||||||
|
throw new ConfigFileException(sprintf('Cannot open file "%s" in mode r', $filename));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (flock($configStream, LOCK_SH)) {
|
if (flock($configStream, LOCK_SH)) {
|
||||||
$content = fread($configStream, filesize($filename));
|
clearstatcache(true, $filename);
|
||||||
|
|
||||||
|
if (($filesize = filesize($filename)) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = fread($configStream, $filesize);
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
throw new ConfigFileException(sprintf('Couldn\'t read file %s', $filename));
|
throw new ConfigFileException(sprintf('Couldn\'t read file %s', $filename));
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ class Cache
|
||||||
$keys = array_keys($config[$category]);
|
$keys = array_keys($config[$category]);
|
||||||
|
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
if (!isset($this->config[$category][$key])) {
|
if (!key_exists($key, $this->config[$category] ?? [])) {
|
||||||
$return[$category][$key] = $config[$category][$key];
|
$return[$category][$key] = $config[$category][$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,6 +311,11 @@ class Cache
|
||||||
if (is_array($cache->config[$category])) {
|
if (is_array($cache->config[$category])) {
|
||||||
$keys = array_keys($cache->config[$category]);
|
$keys = array_keys($cache->config[$category]);
|
||||||
|
|
||||||
|
if (is_null($newConfig[$category] ?? null)) {
|
||||||
|
$newConfig[$category] = [];
|
||||||
|
$newSource[$category] = [];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$newConfig[$category][$key] = $cache->config[$category][$key];
|
$newConfig[$category][$key] = $cache->config[$category][$key];
|
||||||
$newSource[$category][$key] = $cache->source[$category][$key];
|
$newSource[$category][$key] = $cache->source[$category][$key];
|
||||||
|
|
|
@ -276,9 +276,8 @@ class ApiResponse extends Response
|
||||||
'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
|
'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
|
||||||
'request' => $request,
|
'request' => $request,
|
||||||
]);
|
]);
|
||||||
$error = $this->l10n->t('API endpoint %s %s is not implemented', strtoupper($method), $path);
|
$error = $this->l10n->t('API endpoint %s %s is not implemented but might be in the future.', strtoupper($method), $path);
|
||||||
$error_description = $this->l10n->t('The API endpoint is currently not implemented but might be in the future.');
|
|
||||||
|
|
||||||
$this->exit('error', ['error' => ['error' => $error, 'error_description' => $error_description]]);
|
$this->error(501, 'Not Implemented', $error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class PubSub extends \Friendica\BaseModule
|
||||||
|
|
||||||
$this->logger->info('Feed arrived.', ['from' => $this->request->getRemoteAddress(), 'for' => $this->args->getCommand(), 'user-agent' => $this->server['HTTP_USER_AGENT']]);
|
$this->logger->info('Feed arrived.', ['from' => $this->request->getRemoteAddress(), 'for' => $this->args->getCommand(), 'user-agent' => $this->server['HTTP_USER_AGENT']]);
|
||||||
$this->logger->debug('Data stream.', ['xml' => $xml]);
|
$this->logger->debug('Data stream.', ['xml' => $xml]);
|
||||||
$this->logger->debug('Gut request data.', ['request' => $request]);
|
$this->logger->debug('Got request data.', ['request' => $request]);
|
||||||
|
|
||||||
$nickname = $this->parameters['nickname'] ?? '';
|
$nickname = $this->parameters['nickname'] ?? '';
|
||||||
$contact_id = $this->parameters['cid'] ?? 0;
|
$contact_id = $this->parameters['cid'] ?? 0;
|
||||||
|
|
|
@ -71,7 +71,7 @@ class PubSubHubBub extends \Friendica\BaseModule
|
||||||
throw new HTTPException\ForbiddenException();
|
throw new HTTPException\ForbiddenException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->debug('Gut request data.', ['request' => $request]);
|
$this->logger->debug('Got request data.', ['request' => $request]);
|
||||||
|
|
||||||
// Subscription request from subscriber
|
// Subscription request from subscriber
|
||||||
// https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html#rfc.section.5.1
|
// https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html#rfc.section.5.1
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Salmon extends \Friendica\BaseModule
|
||||||
protected function post(array $request = [])
|
protected function post(array $request = [])
|
||||||
{
|
{
|
||||||
$xml = Network::postdata();
|
$xml = Network::postdata();
|
||||||
$this->logger->debug('Gut request data.', ['request' => $request]);
|
$this->logger->debug('Got request data.', ['request' => $request]);
|
||||||
|
|
||||||
$nickname = $this->parameters['nickname'] ?? '';
|
$nickname = $this->parameters['nickname'] ?? '';
|
||||||
if (empty($nickname)) {
|
if (empty($nickname)) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Instance extends BaseDataTransferObject
|
||||||
protected $urls;
|
protected $urls;
|
||||||
/** @var Stats */
|
/** @var Stats */
|
||||||
protected $stats;
|
protected $stats;
|
||||||
/** @var string|null */
|
/** @var string|null This is meant as a server banner, default Mastodon "thumbnail" is 1600×620px */
|
||||||
protected $thumbnail = null;
|
protected $thumbnail = null;
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $languages;
|
protected $languages;
|
||||||
|
@ -91,7 +91,7 @@ class Instance extends BaseDataTransferObject
|
||||||
$this->version = '2.8.0 (compatible; Friendica ' . App::VERSION . ')';
|
$this->version = '2.8.0 (compatible; Friendica ' . App::VERSION . ')';
|
||||||
$this->urls = null; // Not supported
|
$this->urls = null; // Not supported
|
||||||
$this->stats = new Stats($config, $database);
|
$this->stats = new Stats($config, $database);
|
||||||
$this->thumbnail = $baseUrl->get() . ($config->get('system', 'shortcut_icon') ?? 'images/friendica-32.png');
|
$this->thumbnail = $baseUrl->get() . 'images/friendica-banner.jpg';
|
||||||
$this->languages = [$config->get('system', 'language')];
|
$this->languages = [$config->get('system', 'language')];
|
||||||
$this->max_toot_chars = (int)$config->get('config', 'api_import_size', $config->get('config', 'max_import_size'));
|
$this->max_toot_chars = (int)$config->get('config', 'api_import_size', $config->get('config', 'max_import_size'));
|
||||||
$this->registrations = ($register_policy != Register::CLOSED);
|
$this->registrations = ($register_policy != Register::CLOSED);
|
||||||
|
|
|
@ -40,6 +40,7 @@ class CacheTest extends MockedTest
|
||||||
'int' => 235,
|
'int' => 235,
|
||||||
'dec' => 2.456,
|
'dec' => 2.456,
|
||||||
'array' => ['1', 2, '3', true, false],
|
'array' => ['1', 2, '3', true, false],
|
||||||
|
'null' => null,
|
||||||
],
|
],
|
||||||
'config' => [
|
'config' => [
|
||||||
'a' => 'value',
|
'a' => 'value',
|
||||||
|
@ -503,6 +504,24 @@ class CacheTest extends MockedTest
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
/** @see https://github.com/friendica/friendica/issues/12486#issuecomment-1374609349 */
|
||||||
|
'test_with_null' => [
|
||||||
|
'data' => [
|
||||||
|
'test_with_null' => null,
|
||||||
|
'config' => [
|
||||||
|
'register_policy' => 2,
|
||||||
|
'register_text' => '',
|
||||||
|
'sitename' => 'Friendica Social Network23',
|
||||||
|
'hostname' => 'friendica.local',
|
||||||
|
'private_addons' => false,
|
||||||
|
],
|
||||||
|
'system' => [
|
||||||
|
'dbclean_expire_conversation' => 90,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'cat' => 'test_with_null',
|
||||||
|
'assertion' => null,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,10 +530,28 @@ class CacheTest extends MockedTest
|
||||||
*
|
*
|
||||||
* @dataProvider dataTestCat
|
* @dataProvider dataTestCat
|
||||||
*/
|
*/
|
||||||
public function testGetCategory(array $data, string $category, array $assertion)
|
public function testGetCategory($data, string $category, $assertion)
|
||||||
{
|
{
|
||||||
$cache = new Cache($data);
|
$cache = new Cache($data);
|
||||||
|
|
||||||
self::assertEquals($assertion, $cache->get($category));
|
self::assertEquals($assertion, $cache->get($category));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the cache can get merged with different categories
|
||||||
|
*
|
||||||
|
* @dataProvider dataTestCat
|
||||||
|
*/
|
||||||
|
public function testCatMerge($data, string $category)
|
||||||
|
{
|
||||||
|
$cache = new Cache($data);
|
||||||
|
|
||||||
|
$newCache = $cache->merge(new Cache([
|
||||||
|
$category => [
|
||||||
|
'new_key' => 'new_value',
|
||||||
|
],
|
||||||
|
]));
|
||||||
|
|
||||||
|
self::assertEquals('new_value', $newCache->get($category, 'new_key'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -511,4 +511,23 @@ class ConfigFileManagerTest extends MockedTest
|
||||||
|
|
||||||
self::assertNull($configCache->get('system', 'default_timezone'));
|
self::assertNull($configCache->get('system', 'default_timezone'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for empty node.config.php
|
||||||
|
*/
|
||||||
|
public function testEmptyFile()
|
||||||
|
{
|
||||||
|
$this->delConfigFile('node.config.php');
|
||||||
|
|
||||||
|
vfsStream::newFile('node.config.php')
|
||||||
|
->at($this->root->getChild('config'))
|
||||||
|
->setContent('');
|
||||||
|
|
||||||
|
$configFileManager = (new Config())->createConfigFileManager($this->root->url());
|
||||||
|
$configCache = new Cache();
|
||||||
|
|
||||||
|
$configFileManager->setupCache($configCache);
|
||||||
|
|
||||||
|
self::assertEquals(1,1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: 2023.03-dev\n"
|
"Project-Id-Version: 2023.03-dev\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2023-01-08 17:39+0000\n"
|
"POT-Creation-Date: 2023-01-08 17:47+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -5230,12 +5230,7 @@ msgstr ""
|
||||||
|
|
||||||
#: src/Module/Api/ApiResponse.php:279
|
#: src/Module/Api/ApiResponse.php:279
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "API endpoint %s %s is not implemented"
|
msgid "API endpoint %s %s is not implemented but might be in the future."
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/Module/Api/ApiResponse.php:280
|
|
||||||
msgid ""
|
|
||||||
"The API endpoint is currently not implemented but might be in the future."
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Module/Api/Mastodon/Apps.php:64
|
#: src/Module/Api/Mastodon/Apps.php:64
|
||||||
|
|
Loading…
Reference in a new issue