We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
After the array_filter on line 1481 on function hasSingleTagInsideElement the array sometimes not start with 0,
ErrorException
Undefined array key 0
at vendor/j0k3r/php-readability/src/Readability.php:1485 1481▕ $children = array_filter($childNodes, fn ($childNode) => $childNode instanceof \DOMElement); 1482▕ //$children = array_values($children); 1483▕ // There should be exactly 1 element child with given tag 1484▕ ➜ 1485▕ if (1 !== \count($children) || $children[0]->nodeName !== $tag) { 1486▕ return false; 1487▕ } 1488▕ 1489▕ $a = array_filter(
to fix it you have to add array_values to reset the array index.
private function hasSingleTagInsideElement(\DOMElement $node, string $tag): bool { $childNodes = iterator_to_array($node->childNodes); $children = array_filter($childNodes, fn ($childNode) => $childNode instanceof \DOMElement); $children = array_values($children); // There should be exactly 1 element child with given tag if (1 !== \count($children) || $children[0]->nodeName !== $tag) { return false; }
The text was updated successfully, but these errors were encountered:
You might be right. If you can reproduce the bug with a given website & create a test, I'm happy to review the fix :)
Sorry, something went wrong.
Hi @j0k3r yes you can try with my website "https://agenciaweb.net" it's where I tried it and failed.
For example with all pages from golem.de
$url = 'https://www.golem.de/news/anzeige-varta-aa-batterien-grosses-set-zum-kleinen-preis-bei-amazon-2501-192329.html';
$graby = new Graby(); $result = $graby->fetchContent($url);
No branches or pull requests
After the array_filter on line 1481 on function hasSingleTagInsideElement the array sometimes not start with 0,
ErrorException
Undefined array key 0
at vendor/j0k3r/php-readability/src/Readability.php:1485
1481▕ $children = array_filter($childNodes, fn ($childNode) => $childNode instanceof \DOMElement);
1482▕ //$children = array_values($children);
1483▕ // There should be exactly 1 element child with given tag
1484▕
➜ 1485▕ if (1 !== \count($children) || $children[0]->nodeName !== $tag) {
1486▕ return false;
1487▕ }
1488▕
1489▕ $a = array_filter(
to fix it you have to add array_values to reset the array index.
private function hasSingleTagInsideElement(\DOMElement $node, string $tag): bool
{
$childNodes = iterator_to_array($node->childNodes);
$children = array_filter($childNodes, fn ($childNode) => $childNode instanceof \DOMElement);
$children = array_values($children);
// There should be exactly 1 element child with given tag
if (1 !== \count($children) || $children[0]->nodeName !== $tag) {
return false;
}
The text was updated successfully, but these errors were encountered: