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

Uncaught TypeError: fivefilters\\Readability\\Readability::_cleanStyles(): Argument #1 ($node) must be of type .... , fivefilters\\Readability\\Nodes\\DOM\\DOMProcessingInstruction given #38

Closed
mikiescolarmrf opened this issue Mar 7, 2025 · 2 comments

Comments

@mikiescolarmrf
Copy link

It's very similar to this issue, but occurs in a different context.

Following minimal test code shows the behavior. The first page succeeds, the second on fails with the Type Error:

<?php

require __DIR__ . '/vendor/autoload.php';
use fivefilters\Readability\Readability;
use fivefilters\Readability\Configuration;

$readability = new Readability(new Configuration());

$content = file_get_contents('https://support.mozilla.org/en-US/kb/firefox-reader-view-clutter-free-web-pages');
$success = $readability->parse($content);

if ($success) {
    print("The mozilla.org page is fine!" . PHP_EOL);
}

$content = file_get_contents('https://www.adn40.mx/es-tendencia/2025-02-20/fin-a-las-cucarachas-la-fruta-comun-que-las-saca-de-la-cocina');
$success = $readability->parse($content);

if ($success) {
    print("The www.adn40.mx page is fine!");
}

exit($success ? 0 : 1);

Output:

/opt/homebrew/bin/php bug.php
The mozilla.org page is fine!
PHP Fatal error:  Uncaught TypeError: fivefilters\Readability\Readability::_cleanStyles(): Argument #1 ($node) must be of type fivefilters\Readability\Nodes\DOM\DOMDocument|fivefilters\Readability\Nodes\DOM\DOMNode|fivefilters\Readability\Nodes\DOM\DOMElement|fivefilters\Readability\Nodes\DOM\DOMText, fivefilters\Readability\Nodes\DOM\DOMProcessingInstruction given, called in /Users/mescolar/readability-bug/vendor/fivefilters/readability.php/src/Readability.php on line 1781 and defined in /Users/mescolar/readability-bug/vendor/fivefilters/readability.php/src/Readability.php:1758
Stack trace:
#0 /Users/mescolar/readability-bug/vendor/fivefilters/readability.php/src/Readability.php(1781): fivefilters\Readability\Readability->_cleanStyles(Object(fivefilters\Readability\Nodes\DOM\DOMProcessingInstruction))
#1 /Users/mescolar/readability-bug/vendor/fivefilters/readability.php/src/Readability.php(1781): fivefilters\Readability\Readability->_cleanStyles(Object(fivefilters\Readability\Nodes\DOM\DOMElement))
...
@fivefilters
Copy link
Owner

Thank you, looking into this now...

@fivefilters
Copy link
Owner

Fixed in version 3.3.2. Thanks for reporting. 👍

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

No branches or pull requests

2 participants