summaryrefslogtreecommitdiffstats
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
parent11ed50074dd64e5d532cf310a150a77f519a4a0e (diff)
Fix various 15.0 bugs
Issue #821,#820,#819 Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
-rw-r--r--composer.lock20
-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
6 files changed, 36 insertions, 29 deletions
diff --git a/composer.lock b/composer.lock
index 8173ad249..c1592f761 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1333,16 +1333,16 @@
},
{
"name": "sebastian/code-unit",
- "version": "1.0.6",
+ "version": "1.0.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit.git",
- "reference": "d3a241b6028ff9d8e97d2b6ebd4090d01f92fad8"
+ "reference": "59236be62b1bb9919e6d7f60b0b832dc05cef9ab"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/d3a241b6028ff9d8e97d2b6ebd4090d01f92fad8",
- "reference": "d3a241b6028ff9d8e97d2b6ebd4090d01f92fad8",
+ "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/59236be62b1bb9919e6d7f60b0b832dc05cef9ab",
+ "reference": "59236be62b1bb9919e6d7f60b0b832dc05cef9ab",
"shasum": ""
},
"require": {
@@ -1381,7 +1381,7 @@
"type": "github"
}
],
- "time": "2020-09-28T05:28:46+00:00"
+ "time": "2020-10-02T14:47:54+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@@ -1436,16 +1436,16 @@
},
{
"name": "sebastian/comparator",
- "version": "4.0.4",
+ "version": "4.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "e717aabeafe4eac045d3e947dad3207118664c72"
+ "reference": "7a8ff306445707539c1a6397372a982a1ec55120"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e717aabeafe4eac045d3e947dad3207118664c72",
- "reference": "e717aabeafe4eac045d3e947dad3207118664c72",
+ "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/7a8ff306445707539c1a6397372a982a1ec55120",
+ "reference": "7a8ff306445707539c1a6397372a982a1ec55120",
"shasum": ""
},
"require": {
@@ -1502,7 +1502,7 @@
"type": "github"
}
],
- "time": "2020-09-28T05:31:46+00:00"
+ "time": "2020-09-30T06:47:25+00:00"
},
{
"name": "sebastian/diff",
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);
+ }
}
}