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

Better Testing XML Content #1776

Closed
bhsmither opened this issue Oct 19, 2017 · 1 comment
Closed

Better Testing XML Content #1776

bhsmither opened this issue Oct 19, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@bhsmither
Copy link
Contributor

bhsmither commented Oct 19, 2017

In Language->cloneModuleLanguage(), PHP's simplexml_load_file() could return a false or something that looks like false.

Suggest:

if(file_exists($from) && !file_exists($to) && ($content = simplexml_load_file($from)) !== false) {
  if(!isset($content->group) && !isset($content->group[0]->attributes()->name)) return false;

So, additionally, if making an object from the file fails, don't do anything.

If a group does not exist, then it matters not if a string node exists. Testing for a string is probably not what we want to verify anyway. The file is out of compliance with the expected schema.

If group does exist, then we can make the next test to see if there is a name. Otherwise, $content->group[0] is null and calling attributes() on null returns a Fatal Error.

Might want to wrap this in a try/catch block.

Also, it seems to me that only group[0] is processed. That might comply with Language version 1.0 schema, but not with Language version 2.0 schema.

@abrookbanks abrookbanks self-assigned this Feb 23, 2018
@abrookbanks abrookbanks added this to the 6.1.14 milestone Feb 23, 2018
@abrookbanks
Copy link
Member

Works well. Thank you.

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

No branches or pull requests

2 participants