Hi,
I have been using this module for a while without problem, but today I came across a error when updating an array.
The field is an unlimited texteared.
Here is the example:
{
"field_leverans_adress":["asdasd32", "other option"]
}
The error;
Recoverable fatal error: Argument 2 passed to RestWSBaseFormat::getResourceReferenceValue() must be of the type array, string given, called in /Users/xx/Sites/pv/SERVER/production/sites/all/modules/restws/restws.formats.inc on line 274 and defined in RestWSBaseFormat->getResourceReferenceValue() (line 307 of /Users/xx/Sites/pv/SERVER/production/sites/all/modules/restws/restws.formats.inc).
How can I fix that? thanks in advance
Comments
Comment #1
sebastiannm commentedI noticed that the error only happens when the format of the field is plan text
Comment #1.0
sebastiannm commentedAdding som extra info
Comment #2
tdiprima33 commentedHi There!
I attached a patch: 2070213-fix-error-on-array.patch
Basically, if you are trying to populate a text field, and that field can have unlimited values (essentially, an Array), the code is attempting to manipulate that array. It is calling method getResourceReferenceValue, and that is where the code is failing.
Recoverable fatal error: Argument 2 passed to RestWSBaseFormat::getResourceReferenceValue() must be an array, string given, called in [drupal]/sites/all/modules/restws/restws.formats.inc on line 294 and defined in RestWSBaseFormat->getResourceReferenceValue() (line 334 of [drupal]/sites/all/modules/restws/restws.formats.inc).
Not only is running this code unnecessary, but calling getResourceReferenceValue throws an error:
$list_value = $this->getResourceReferenceValue($list_type, $list_value);
Cheers!
Tammy
Comment #3
tdiprima33 commentedComment #4
tdiprima33 commentedComment #6
mkolar commentedI had exactly same problem... Entity with field with multivalue text (plain_text).. This patch do the trick, no more errors with this patch and entity is saved with all given values.
Comment #7
roppa_uk commentedI have the same problem. I had to add the patch manually but it still didn't work. This is a real issue for us.
Comment #8
PovilasID commentedPatch breaks intended architecture and results in compatibility issues in more complex structures.
It seams that code author has forgotten to implement simple text field array in
getResourceReferenceValueit should be an easy fix for code author.I applied a dirty fix for my particular case (line 275):
However this needs more broad scope approach that would encompass other common cases like text fields etc.
P.S. This of course effects not only PUT but also POST queries and before this issue is fixed none of multiple value text field based content is saved which is a major issue
Comment #9
PovilasID commented