summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-10-02 19:41:40 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-10-03 14:01:36 +0200
commit167dc70238cc4c82e46714fe55a516d48c0d6c76 (patch)
treec1222956d8bab43aa79bfc6fc018ad1891215dd5 /lib
parent11ed50074dd64e5d532cf310a150a77f519a4a0e (diff)
Fix various 15.0 bugs
Issue #821,#820,#819 Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php4
-rw-r--r--lib/Config/LegacyConfig.php13
-rw-r--r--lib/Db/Item.php4
-rw-r--r--lib/Db/ItemMapperV2.php12
-rw-r--r--lib/Service/FeedServiceV2.php12
5 files changed, 26 insertions, 19 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 88cba4752..b22775924 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -151,7 +151,7 @@ class Application extends App implements IBootstrap
});
//TODO: Remove code after 15.1
- $context->registerService('ConfigView', function (ContainerInterface $c): ?Node {
+ $context->registerService('ConfigFolder', function (ContainerInterface $c): ?Node {
/** @var IRootFolder $fs */
$fs = $c->get(IRootFolder::class);
$path = 'news/config';
@@ -165,7 +165,7 @@ class Application extends App implements IBootstrap
//TODO: Remove code after 15.1
$context->registerService(LegacyConfig::class, function (ContainerInterface $c): LegacyConfig {
$config = new LegacyConfig(
- $c->get('ConfigView'),
+ $c->get('ConfigFolder'),
$c->get(LoggerInterface::class)
);
$config->read($c->get('configFile'), false);
diff --git a/lib/Config/LegacyConfig.php b/lib/Config/LegacyConfig.php
index 370638843..f011a0e4a 100644
--- a/lib/Config/LegacyConfig.php
+++ b/lib/Config/LegacyConfig.php
@@ -22,7 +22,9 @@ use Psr\Log\LoggerInterface;
class LegacyConfig
{
+ private $logger;
private $fileSystem;
+
public $autoPurgeMinimumInterval; // seconds, used to define how
// long deleted folders and feeds
// should still be kept for an
@@ -31,8 +33,6 @@ class LegacyConfig
public $maxRedirects; // seconds
public $feedFetcherTimeout; // seconds
public $useCronUpdates; // turn off updates run by the cron
- public $logger;
- public $loggerParams;
public $maxSize;
public $exploreUrl;
public $updateInterval;
@@ -42,15 +42,15 @@ class LegacyConfig
LoggerInterface $logger
) {
$this->fileSystem = $fileSystem;
+ $this->logger = $logger;
+
$this->autoPurgeMinimumInterval = 60;
$this->autoPurgeCount = 200;
$this->maxRedirects = 10;
$this->maxSize = 100 * 1024 * 1024; // 100Mb
$this->feedFetcherTimeout = 60;
$this->useCronUpdates = true;
- $this->logger = $logger;
$this->exploreUrl = '';
- $this->loggerParams = ['app' => Application::NAME];
$this->updateInterval = 3600;
}
@@ -63,10 +63,7 @@ class LegacyConfig
$configValues = parse_ini_string($content);
if ($configValues === false || count($configValues) === 0) {
- $this->logger->warning(
- 'Configuration invalid. Ignoring values.',
- $this->loggerParams
- );
+ $this->logger->warning('Configuration invalid. Ignoring values.');
} else {
foreach ($configValues as $key => $value) {
if (property_exists($this, $key)) {
diff --git a/lib/Db/Item.php b/lib/Db/Item.php
index d7efdd14b..37497049c 100644
--- a/lib/Db/Item.php
+++ b/lib/Db/Item.php
@@ -591,9 +591,11 @@ class Item extends Entity implements IAPI, \JsonSerializable
*
* @return boolean
*/
- public function isSupportedMime(string $mime): bool
+ public function isSupportedMime(?string $mime): bool
{
+
return (
+ $mime !== null ||
stripos($mime, 'audio/') !== false ||
stripos($mime, 'image/') !== false ||
stripos($mime, 'video/') !== false);
diff --git a/lib/Db/ItemMapperV2.php b/lib/Db/ItemMapperV2.php
index edb8ba55f..222340744 100644
--- a/lib/Db/ItemMapperV2.php
+++ b/lib/Db/ItemMapperV2.php
@@ -95,12 +95,18 @@ class ItemMapperV2 extends NewsMapperV2
return $this->findEntity($builder);
}
- public function findByGuidHash(string $getGuidHash): Item
+ public function findByGuidHash(string $guidHash): Item
{
- throw new DoesNotExistException('fasi');
+ $builder = $this->db->getQueryBuilder();
+ $builder->addSelect('*')
+ ->from($this->tableName)
+ ->andWhere('guid_hash = :guid_hash')
+ ->setParameter(':guid_hash', $guidHash, IQueryBuilder::PARAM_STR);
+
+ return $this->findEntity($builder);
}
- public function findAllForFeed(int $feedId)
+ public function findAllForFeed(int $feedId): array
{
$builder = $this->db->getQueryBuilder();
$builder->addSelect('*')
diff --git a/lib/Service/FeedServiceV2.php b/lib/Service/FeedServiceV2.php
index 41fb41e89..2304c3286 100644
--- a/lib/Service/FeedServiceV2.php
+++ b/lib/Service/FeedServiceV2.php
@@ -250,7 +250,7 @@ class FeedServiceV2 extends Service
*
* @return Feed|Entity Database feed entity
*/
- public function fetch(Feed $feed)
+ public function fetch(Feed $feed): Entity
{
if ($feed->getPreventUpdate() === true) {
return $feed;
@@ -321,19 +321,21 @@ class FeedServiceV2 extends Service
return $this->mapper->update($feed);
}
- public function delete(string $user, int $id)
+ public function delete(string $user, int $id): void
{
$feed = $this->mapper->findFromUser($user, $id);
$this->mapper->delete($feed);
}
- public function purgeDeleted()
+ public function purgeDeleted(): void
{
$this->mapper->purgeDeleted();
}
- public function fetchAll()
+ public function fetchAll(): void
{
- return $this->mapper->findAll();
+ foreach ($this->findAll() as $feed) {
+ $this->fetch($feed);
+ }
}
}