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

Unable to add the json-schema meta-schema v4 to SchemaStore #19

Open
jansc opened this issue Dec 4, 2014 · 1 comment
Open

Unable to add the json-schema meta-schema v4 to SchemaStore #19

jansc opened this issue Dec 4, 2014 · 1 comment

Comments

@jansc
Copy link

jansc commented Dec 4, 2014

Hi. I'm having trouble with adding the draft-04 meta schema to the schema store.

<?php

$store = new SchemaStore();

$url = "http://json-schema.org/draft-04/schema#";
$schema = json_decode(file_get_contents($url));

$store->add($url, $schema);

?>

This will result in the following error:

PHP Fatal error:  Maximum function nesting level of '100' reached, aborting! in /Users/jans/jsv4-php/schema-store.php on line 45
PHP Stack trace:
PHP   1. {main}() /Users/jans/jsv4-php/test.php:0
PHP   2. runTests() /Users/jans/jsv4-php/test.php:111
PHP   3. runTests() /Users/jans/jsv4-php/test.php:106
PHP   4. runPhpTest() /Users/jans/jsv4-php/test.php:74
PHP   5. include_once() /Users/jans/jsv4-php/test.php:52
PHP   6. SchemaStore->add() /Users/jans/jsv4-php/tests/03 - schema store/04 - addmetaschema.php:8
PHP   7. SchemaStore->get() /Users/jans/jsv4-php/schema-store.php:132
PHP   8. SchemaStore->add() /Users/jans/jsv4-php/schema-store.php:188
PHP   9. SchemaStore->get() /Users/jans/jsv4-php/schema-store.php:132
PHP  10. SchemaStore->add() /Users/jans/jsv4-php/schema-store.php:188
PHP  11. SchemaStore->get() /Users/jans/jsv4-php/schema-store.php:132
PHP  12. SchemaStore->add() /Users/jans/jsv4-php/schema-store.php:188
PHP  13. SchemaStore->normalizeSchema() /Users/jans/jsv4-php/schema-store.php:125
PHP  14. SchemaStore->normalizeSchema() /Users/jans/jsv4-php/schema-store.php:167
PHP  15. SchemaStore->normalizeSchema() /Users/jans/jsv4-php/schema-store.php:167
PHP  16. SchemaStore->normalizeSchema() /Users/jans/jsv4-php/schema-store.php:167
PHP  17. SchemaStore->normalizeSchema() /Users/jans/jsv4-php/schema-store.php:167

[...]

PHP  98. SchemaStore->normalizeSchema() /Users/jans/jsv4-php/schema-store.php:167
PHP  99. SchemaStore::resolveUrl() /Users/jans/jsv4-php/schema-store.php:159

I'm using following PHP version:

PHP 5.4.32 (cli) (built: Sep  4 2014 08:29:44) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

Did I misunderstand how adding schemas to the schema store works? Thanks in advance for your help.

@krixi
Copy link

krixi commented Aug 19, 2015

I can confirm, this issue is still present. I am trying to add the hyper-schema, but the problem is the same.

I have looked into this issue and it seems that because the json-schema is self-referencing ('$ref' => '#'), the code creates a self-referencing object. The recursive nature of normalizeSchema does not check for this, and the code ends up going into an infinite recursive loop.

I will continue looking at this, but any suggestions are greatly appreciated.

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