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

Host system complaining when item in one item group doesn't have the 'optional' property #60

Open
otacke opened this issue May 5, 2019 · 4 comments

Comments

@otacke
Copy link
Contributor

otacke commented May 5, 2019

On the release version, this part of the code

foreach ($semantics->fields as $field) {
if (!(isset($field->optional) && $field->optional)) {
// Check if field is in group.
if (! property_exists($group, $field->name)) {
//$this->h5pF->setErrorMessage($this->h5pF->t('No value given for mandatory field ' . $field->name));
}
}
}

yields

Warning: First parameter must either be an object or the name of an existing class in /foo/h5p/h5p-php-library/h5p.classes.php on line 3893

if there's a group that contains only one item and the optional property is not set.

I think that's actually a problem with core turning a one item group from an array with one object into just an object. The default property then has to be set on the group, not on the item, in order to be used correctly by the editor. The code referenced above, however, doesn't use that one leading to the error message if the optional property is not set for the item.

@otacke otacke changed the title Host system complaining Host system complaining when item in one item group doesn't have the 'optional' property May 5, 2019
@icc
Copy link
Member

icc commented May 6, 2019

I believe this has been fixed in 70278d1, but hasn't been released yet. Are you able to confirm?

@otacke
Copy link
Contributor Author

otacke commented May 6, 2019

Ah, nice. Give me some time to upgrade an instance to the master branch and check it, please.

@otacke
Copy link
Contributor Author

otacke commented May 6, 2019

The problem remains using the master branch. If you have a one item group in semantics that has a default property, but the optional property is not set to true, you still receive the warning message.

@icc
Copy link
Member

icc commented May 6, 2019

Ok, going to have to look into it.

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