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

modRestService and empty XML tags #13132

Closed
Jako opened this issue Sep 24, 2016 · 4 comments
Closed

modRestService and empty XML tags #13132

Jako opened this issue Sep 24, 2016 · 4 comments
Labels
bug The issue in the code or project, which should be addressed.

Comments

@Jako
Copy link
Collaborator

Jako commented Sep 24, 2016

Summary

Bug or feature: Empty XML tags are converted into empty arrays in _xml2array method.

Step to reproduce

POST/PUT an empty tag to the modRestService

Observed behavior

The value is converted into an empty array.

Expected behavior

I would suggest, that it should be converted into null or into an empty string. But that's a design decision.

@pixelchutes
Copy link
Contributor

Do we have any knowledge of internal logic currently relying on this behavior?

@Jako
Copy link
Collaborator Author

Jako commented Sep 26, 2016

I haven't. With the current code it is not possible to update a record value with an empty value using the default put method. The value would contain Array after the put.

Those values have to be handled by a beforePut method

    public function beforePut()
    {
        foreach ($this->object->_fields as $fieldname => $field) {
            if (is_array($field) && empty($field)) {
                $this->object->set($fieldname, '');
            }
        }
        return true;
    }

@pixelchutes
Copy link
Contributor

Do you have an example model (field/data type) this can be tested with? Looking to reproduce / verify, though I've only ever used JSON w/ modRestService.

@pixelchutes
Copy link
Contributor

I was able to verify this report using a modRestController and an XML payload.

Updating via PUT using XML with empty string definitely is converting to Array. This does not happen when using JSON payloads, which appear to be functioning as expected.

My vote is that this is a bug 🐛

@Mark-H Mark-H added bug The issue in the code or project, which should be addressed. state/accepting-pull-request and removed state/awaiting-feedback labels Feb 9, 2017
@alroniks alroniks closed this as completed Mar 6, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed.
Projects
None yet
Development

No branches or pull requests

4 participants