Skip to content

Commit

Permalink
Merge pull request #47 from Sarke/jsonld-blank-item
Browse files Browse the repository at this point in the history
Fix #45, blank nodes
  • Loading branch information
rvanlaak authored Dec 10, 2019
2 parents ebf10df + 7feb791 commit f093c49
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Micrometa/Infrastructure/Parser/JsonLD.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ protected function parseNode(NodeInterface $node)
*/
protected function parseNodeType(NodeInterface $node): array
{
if ($node->isBlankNode()) {
return [];
}

/** @var NodeInterface|NodeInterface[] $itemTypes */
$itemTypes = $node->getType();
$itemTypes = is_array($itemTypes) ? $itemTypes : [$itemTypes];
Expand Down

3 comments on commit f093c49

@jessarcher
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing a bunch of Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException: Empty type list is not allowed errors for me. I don't have time right now to try to dig into exactly why so I need to pin my version to 3.0.1.

@rvanlaak
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jessarcher can you share some fixtures with us (in a new issue) so we can dive into this? Please also add a stack trace or description on what methods are used when you get this exception.

@ankurgoels
Copy link

@ankurgoels ankurgoels commented on f093c49 Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvanlaak Here is the stack trace from laravel. Hope this helps.
Empty type list is not allowed {"exception":"[object] (Jkphl\\Micrometa\\Domain\\Exceptions\\InvalidArgumentException(code: 1488314667): Empty type list is not allowed at <path>\micrometa\\src\\Micrometa\\Domain\\Item\\ItemSetupTrait.php:124) [stacktrace] #0 <path>\micrometa\\src\\Micrometa\\Domain\\Item\\ItemSetupTrait.php(104): Jkphl\\Micrometa\\Domain\\Item\\Item->valTypes(Array) #1 <path>\micrometa\\src\\Micrometa\\Domain\\Item\\Item.php(77): Jkphl\\Micrometa\\Domain\\Item\\Item->setup(Object(Jkphl\\Micrometa\\Application\\Factory\\PropertyListFactory), Array, Array, '_:b0', '') #2 <path>\micrometa\\src\\Micrometa\\Application\\Item\\Item.php(92): Jkphl\\Micrometa\\Domain\\Item\\Item->__construct(Array, Array, '_:b0', NULL, Object(Jkphl\\Micrometa\\Application\\Factory\\PropertyListFactory)) #3 <path>\micrometa\\src\\Micrometa\\Application\\Factory\\ItemFactory.php(158): Jkphl\\Micrometa\\Application\\Item\\Item->__construct(4, Object(Jkphl\\Micrometa\\Application\\Factory\\PropertyListFactory), Array, Array, Array, '_:b0', NULL, NULL) #4 [internal function]: Jkphl\\Micrometa\\Application\\Factory\\ItemFactory->__invoke(Object(stdClass)) #5 <path>\micrometa\\src\\Micrometa\\Infrastructure\\Parser\\ParsingResult.php(77): array_map(Object(Jkphl\\Micrometa\\Application\\Factory\\ItemFactory), Array) #6 <path>\micrometa\\src\\Micrometa\\Infrastructure\\Parser\\JsonLD.php(125): Jkphl\\Micrometa\\Infrastructure\\Parser\\ParsingResult->__construct(4, Array) #7 <path>\micrometa\\src\\Micrometa\\Application\\Service\\ExtractorService.php(60): Jkphl\\Micrometa\\Infrastructure\\Parser\\JsonLD->parseDom(Object(DOMDocument)) #8 <path>\micrometa\\src\\Micrometa\\Ports\\Parser.php(146): Jkphl\\Micrometa\\Application\\Service\\ExtractorService->extract(Object(DOMDocument), Object(Jkphl\\Micrometa\\Infrastructure\\Parser\\JsonLD)) #9 <path>\micrometa\\src\\Micrometa\\Ports\\Parser.php(108): Jkphl\\Micrometa\\Ports\\Parser->extractItems(Object(DOMDocument), Object(Generator)) #10 Jkphl\\Micrometa\\Ports\\Parser->__invoke('https://stackov...')

@jessarcher Thanks for highlighting the issue.

Please sign in to comment.