Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP Error/Warnning #279

Merged
merged 1 commit into from
Jan 7, 2022
Merged

Fix PHP Error/Warnning #279

merged 1 commit into from
Jan 7, 2022

Conversation

girishpanchal30
Copy link
Contributor

@girishpanchal30 girishpanchal30 commented Jan 7, 2022

  • PHP Warning: array_combine(): Both parameters should have an equal number

  • PHP Warning: DOMDocument::saveXML(): unknown encoding

  • PHP Fatal error: Uncaught TypeError: Typed property Graby\Extractor\ContentExtractor::$title must be string or null

issue - #278

@coveralls
Copy link

coveralls commented Jan 7, 2022

Coverage Status

Coverage decreased (-0.06%) to 95.251% when pulling 23aed1e on girishpanchal30:master into 026abfe on j0k3r:master.

@j0k3r
Copy link
Owner

j0k3r commented Jan 7, 2022

Looks great, you can squash your commits 👍

Fix PHP Error/Warnning j0k3r#278

Move http_header definition before condition j0k3r#278

Move http_header array_merge before condition j0k3r#278

Fix cs fixer & PHPStan error j0k3r#278
@j0k3r
Copy link
Owner

j0k3r commented Jan 7, 2022

Thanks @girishpanchal30!

@j0k3r j0k3r merged commit 526c18f into j0k3r:master Jan 7, 2022
Comment on lines +335 to +337
if (\count($currentConfig->find_string) !== \count($currentConfig->replace_string)) {
return $currentConfig;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks weird to me. Sohuld not we rather return $newConfig? And should not we check the variables from $newConfig? I would assume the $currentConfig has been already validated upon construction.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'll move that check in parseLines instead

@@ -201,8 +201,8 @@ public function process(string $html, string $url, SiteConfig $siteConfig = null
$this->readability = $this->getReadability($html, $url, $parser, $this->siteConfig->tidy() && $smartTidy);
$tidied = $this->readability->tidied;

$this->logger->info('Body size after Readability: {length}', ['length' => \strlen((string) $this->readability->dom->saveXML())]);
$this->logger->debug('Body after Readability', ['dom_saveXML' => $this->readability->dom->saveXML()]);
$this->logger->info('Body size after Readability: {length}', ['length' => \strlen((string) $this->readability->dom->saveXML($this->readability->dom->documentElement))]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If https://www.php.net/manual/en/domdocument.savexml.php#44422 is correct, this would just save a page from unknown encoding as UTF-8. No idea how would it try to do that, possibly leading to some corruption.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, but that's not really a problem as it's inside the log, maybe the log will only be unreadable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants