semsol / arc2

ARC RDF Classes for PHP
Other
332 stars 89 forks source link

Warning in TurtleParser when parsing typed literals. #155

Open cgutteridge opened 4 months ago

cgutteridge commented 4 months ago

PHP 8.0.30 (cli) (built: Aug 3 2023 17:13:08) ( NTS gcc x86_64 ) [12.15s] PHP Warning: Trying to access array offset on value of type int in /srv/hedgehog/app/phplib/composer/vendor/semsol/arc2/parsers/ARC2_TurtleParser.php on line 566

PHP Version PHP 8.0.30 (cli) (built: Aug 3 2023 17:13:08) ( NTS gcc x86_64 )

It only seems to happen on lines with a typed literal, and not every time that line shows up. eg. a file of 1000 identical triples: http://id.southampton.ac.uk/building/FOO http://www.w3.org/2004/02/skos/core#notation "FOO"^^http://id.southampton.ac.uk/ns/building-code-scheme .

causes only a few warnings, not one per line

I've done some debugging and the warning is in xRDFLiteral when sometimes the value of $v seems to be truncated eg.: string(51) " "FOO"^^<http://id.southampton.ac.uk/ns/building-co"

It feels like it's reading in blocks of data and ensuring it's got a full triple but not checking that the ^^ part is complete too?

k00ni commented 4 months ago

Thanks for the report, even though I lack the time to have a deeper look. Feel free to dig deeper (+PR) and I will be happy to help.