Skip to content

Fix wrong usage of https in the monolog.xml file #11168

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

Closed
wants to merge 1 commit into from
Closed

Fix wrong usage of https in the monolog.xml file #11168

wants to merge 1 commit into from

Conversation

PaddyS
Copy link

@PaddyS PaddyS commented Mar 15, 2019

The monolog.xml examples mixup 'http' and https, which results in the XML configuration being invalid.

The mixup results in the XmlFileLoader being unable to properly replace the URL with the actual local path, so he tries to load the actual URL, which is not available.

This also happened for the services.xsd - but since it's also available via URL, that's not an actual issue.

Should I also change that?

@javiereguiluz
Copy link
Member

I never use XML, so this is not easy for me ... but maybe the reason of the error is that neither the HTTP nor the HTTPS version of the monolog XSD file exists on symfony.com?

404 error -> http://symfony.com/schema/dic/monolog/monolog-1.0.xsd
404 error -> https://symfony.com/schema/dic/monolog/monolog-1.0.xsd
200 OK -> http://symfony.com/schema/dic/services/services-1.0.xsd
200 OK -> https://symfony.com/schema/dic/services/services-1.0.xsd

Maybe @xabbuh or @OskarStark can help us here.

@OskarStark
Copy link
Contributor

OskarStark commented Mar 15, 2019

This could be the reason Javier, mixing such URLs does not result in invalid XML per definition.
Before I changed this in PR I talked to @fabpot and he told me (and that makes sense) that all of them should be switched.
But the question is here, http and S for Monolog are 404, how could it work before ?! 🤔

In the end the URL should work and this PR closed. Thank you for pointing this out @PaddyS 👌🏻

@wouterj
Copy link
Member

wouterj commented Mar 16, 2019

That's not the case, @javiereguiluz. Namespaces (the first, third, fifth, etc URL in xsi:schemaLocation are always URLs in XML. However, these just acts as keys in a key-value store, so the namespace URL doesn't have to exists.

Then, the XSD file (the second, forth, sixth, etc URL in xsi:schemaLocation) sometimes exists on the online version. However, in Symfony this is not the case:

$ns = $extension->getNamespace();
$path = str_replace([$ns, str_replace('http://', 'https://', $ns)], str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]);

In short, the XML namespace is replaced by Extension#getXsdValidationBasePath() in the XSD url. Evenmore, we can see that also the https:// version of the XML namespace is replaced. Extension#getXsdValidationBasePath() references the file location of the XSD in the bundle.

Thus:

XML namespace XSD url location
http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd %base_path%/services-1.0.xsd
http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd %base_path%/services-1.0.xsd
https://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd %base_path%/services-1.0.xsd
https://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/services/services-1.0.xsd
https://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/foo/bar/services-1.0.xsd %base_path%/foo/bar/services-1.0.xsd

These changes are however only made recently: symfony/symfony@95e90b8 It is not yet included in a release, so PR changing this in the docs was merged too quickly.

Given it's about to be released in all versions, I would vote to close this PR. If we think it is a problem to have this bug in the docs for 2 weeks, we should merge this one and revert the merge of #11122

@xabbuh
Copy link
Member

xabbuh commented Mar 17, 2019

I am now wondering if the changes in the code don't have to be reverted as otherwise XML configs that were valid before will soon become invalid.

@wouterj
Copy link
Member

wouterj commented Mar 17, 2019

That's not true. Previously, everything was http only. Now, https is also supported

@PaddyS
Copy link
Author

PaddyS commented Mar 18, 2019

Thanks @wouterj for pointing out the commit, which is going to include https in the XmlFileLoader soon.
Actually I'm totally fine with closing my PR, if that issue is going to be fixed in Symfony itself. 👍

Yet I am not quite familiar with how the versioning of the docs work here.
Shouldn't that change to the documentation be part of the Symfony 4.3 (master) doc version in the meanwhile, until the commit to the XmlFileLoader gets merged into Symfony 4.2.*?
Not sure what's the proper workflow here.

@wouterj
Copy link
Member

wouterj commented Mar 18, 2019

Yeah, normally I would assume it should target 4.3. But for some reason the PR was merged into 3.4 in the code: symfony/symfony@95e90b8

In the docs, we try to follow Symfony's versions as close as possible

@wouterj
Copy link
Member

wouterj commented Mar 18, 2019

Thanks for your PR btw! Unfortunately, I'm going to close it, but looking forward to other contributions from you! 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants