You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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))
...
The text was updated successfully, but these errors were encountered:
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:
Output:
The text was updated successfully, but these errors were encountered: