jkphl/micrometa

Endless parsing

clxo opened this issue · 1 comments

clxo commented

Hi!

The JSON-LD micrometa 2 parser can't finish if the url of @id and http://schema.org/sameAs property is the same.
I used the following script for testing:

<?php
require_once  'vendor/autoload.php';
use Jkphl\Micrometa\Ports\Parser;

$htmlSource_jsonld = '<!DOCTYPE html>
<html>
    <head>
        <script type="application/ld+json">
        {
          "@context": "http://schema.org",
          "@type": "organization",
          "@id": "http://www.website.de",
          "sameAs": "http://www.website.de"
        }
        </script>
    </head>
    <body></body>
</html>';

$time_start = microtime(true);

$objMicrometa = new Parser();
$result = $objMicrometa("http://www.website.de", $htmlSource_jsonld);

$time_end = microtime(true);
$time = $time_end - $time_start;
echo "\n $time Seconds Runtime";
clxo commented

Update: There is somewhere a endless recursion in Micrometa/Infrastructure/Parser/JsonLD->parseNodeProperties(NodeInterface $node).
I drawed a UML activity diagram that shows the endless loop:

micrometa_bug