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

Improved error message when external schema cannot be found #852

Merged
merged 1 commit into from Jan 8, 2015

Conversation

mpscholten
Copy link
Member

This improves the error message when you include an external schema which could not be found by propel. Currently you get the following error:

Warning: DOMDocument::load(): Empty string supplied as input

Now you get

Unable to find external schema 'my-external-schema.xml'

Propel applies realpath to the path given by the user. If realpath cannot resolve the given path it'll return false. Now false is given to DOMDocument::load, which logs a php warning because of invalid input.

@@ -364,6 +364,11 @@ protected function includeExternalSchemas(\DOMDocument $dom, $srcDir)

$externalSchema->parentNode->removeChild($externalSchema);

$path = realpath($include);
if (!$path) {
throw new BuildException("Unable to find external schema '$path'");
Copy link
Member

Choose a reason for hiding this comment

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

$include instead of $path

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing out :)

@staabm
Copy link
Member

staabm commented Jan 6, 2015

Looks good, thx 👍 maybe add a unit test?

@@ -364,8 +364,13 @@ protected function includeExternalSchemas(\DOMDocument $dom, $srcDir)

$externalSchema->parentNode->removeChild($externalSchema);

$path = realpath($include);
if (!$path) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just file_exists on $include? It resolves symlinks on its own.

Copy link
Member

Choose a reason for hiding this comment

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

Should we also check is_readable?

Copy link
Member

Choose a reason for hiding this comment

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

probably a good idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't is_readable without file_exists also works? is_readable basically includes file_exists

@mpscholten
Copy link
Member Author

maybe add a unit test?

We don't have unit tests for this class at the moment. Not sure whether it's worth it to add them for this small change.

@marcj
Copy link
Member

marcj commented Jan 6, 2015

I don't think its worth, but if you are incredible motivated, it won't hurt. :D

Sent from my iPhone

Am 06.01.2015 um 12:36 schrieb Marc Scholten notifications@github.com:

maybe add a unit test?

We don't have unit tests for this class at the moment. Not sure whether it's worth it to add them for this small change.


Reply to this email directly or view it on GitHub.

@mpscholten
Copy link
Member Author

Haha no. Just wanted to fix my php warning, and then thought this might be useful for other people to :)

Am 06.01.2015 um 12:45 schrieb Marc J. Schmidt notifications@github.com:

I don't think its worth, but if you are incredible motivated, it won't hurt. :D

Sent from my iPhone

Am 06.01.2015 um 12:36 schrieb Marc Scholten notifications@github.com:

maybe add a unit test?

We don't have unit tests for this class at the moment. Not sure whether it's worth it to add them for this small change.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub.

@mpscholten
Copy link
Member Author

Just added is_readable as suggested. Could you take a look again?

@@ -364,6 +364,10 @@ protected function includeExternalSchemas(\DOMDocument $dom, $srcDir)

$externalSchema->parentNode->removeChild($externalSchema);

if (!is_readable($include)) {
throw new BuildException("Unable to find external schema '$include'");
Copy link
Member

Choose a reason for hiding this comment

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

"Either does not exist or is not readable"

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, just updated it

@marcj
Copy link
Member

marcj commented Jan 8, 2015

Ok, cool, thanks! 😃

marcj added a commit that referenced this pull request Jan 8, 2015
Improved error message when external schema cannot be found
@marcj marcj merged commit 2c0eacb into propelorm:master Jan 8, 2015
@mpscholten mpscholten deleted the fix-external-schema-error branch January 8, 2015 17:57
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.

None yet

3 participants