Skip to content

Report why fetching an IANA bootstrap file failed - #10

Open
tomsommer wants to merge 1 commit into
ArrayAccess:mainfrom
tomsommer:fix-bootstrap-fetch-error
Open

tomsommer wants to merge 1 commit into
ArrayAccess:mainfrom
tomsommer:fix-bootstrap-fetch-error

Conversation

@tomsommer

Copy link
Copy Markdown

Related to #4.

When file_get_contents() fails to download an IANA bootstrap file, AbstractRdapService::fromURL() swallowed the PHP warning and threw:

Protocol service URL "https://data.iana.org/rdap/dns.json" return invalid data

That made #4 hard to diagnose; the real cause there was allow_url_fopen=0. Now the first PHP warning is included:

Could not fetch protocol service URL "https://data.iana.org/rdap/dns.json": file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0

The exception class is still InvalidServiceDefinitionException, so existing catch blocks keep working. Content that downloads but is not a valid bootstrap file still produces the "return invalid data" message.

With allow_url_fopen disabled, the bootstrap files and RDAP queries can now go through a PSR-18 client instead (#6):

$client = new Client(new Psr18Client());

phpcs and phpstan pass; checked with php -d allow_url_fopen=0 and with it enabled.

When file_get_contents() fails (for example with allow_url_fopen=0),
the PHP warning was swallowed and the error claimed the URL returned
invalid data. Throw with the first warning instead.
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

Successfully merging this pull request may close these issues.

1 participant