Retain imported content if fetching fails, fixes #2658
This commit is contained in:
parent
1093e979ff
commit
29dca43236
@ -21,14 +21,16 @@ class ContentProxy
|
|||||||
protected $logger;
|
protected $logger;
|
||||||
protected $tagRepository;
|
protected $tagRepository;
|
||||||
protected $mimeGuesser;
|
protected $mimeGuesser;
|
||||||
|
protected $fetchingErrorMessage;
|
||||||
|
|
||||||
public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, LoggerInterface $logger)
|
public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, LoggerInterface $logger, $fetchingErrorMessage)
|
||||||
{
|
{
|
||||||
$this->graby = $graby;
|
$this->graby = $graby;
|
||||||
$this->tagger = $tagger;
|
$this->tagger = $tagger;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->tagRepository = $tagRepository;
|
$this->tagRepository = $tagRepository;
|
||||||
$this->mimeGuesser = new MimeTypeExtensionGuesser();
|
$this->mimeGuesser = new MimeTypeExtensionGuesser();
|
||||||
|
$this->fetchingErrorMessage = $fetchingErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +50,10 @@ class ContentProxy
|
|||||||
{
|
{
|
||||||
// do we have to fetch the content or the provided one is ok?
|
// do we have to fetch the content or the provided one is ok?
|
||||||
if (empty($content) || false === $this->validateContent($content)) {
|
if (empty($content) || false === $this->validateContent($content)) {
|
||||||
$content = $this->graby->fetchContent($url);
|
$fetchedContent = $this->graby->fetchContent($url);
|
||||||
|
if (empty($content) || $fetchedContent['html'] !== $this->fetchingErrorMessage) {
|
||||||
|
$content = $fetchedContent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $content['title'];
|
$title = $content['title'];
|
||||||
|
@ -86,6 +86,7 @@ services:
|
|||||||
- "@wallabag_core.rule_based_tagger"
|
- "@wallabag_core.rule_based_tagger"
|
||||||
- "@wallabag_core.tag_repository"
|
- "@wallabag_core.tag_repository"
|
||||||
- "@logger"
|
- "@logger"
|
||||||
|
- '%wallabag_core.fetching_error_message%'
|
||||||
|
|
||||||
wallabag_core.rule_based_tagger:
|
wallabag_core.rule_based_tagger:
|
||||||
class: Wallabag\CoreBundle\Helper\RuleBasedTagger
|
class: Wallabag\CoreBundle\Helper\RuleBasedTagger
|
||||||
|
Loading…
x
Reference in New Issue
Block a user