Warning: SimpleXMLElement::addChild() expects parameter 2 to be string, array given in Redmine/Api/Issue.php on line 145

Fixed the fact that when trying to update a custom field in an issue a PHP error gets generated.

Previously, the code would loop through all key-value pairs and try to attach the value as a string.

When hitting key='custom_fields' it would encounter an array as the value and this would fail.

There was existing additional logic to deal with this scenario when creating a new issue, but not when updating an old one.

I have moved the code from create() that generates the XML into into its own function, and then called this function from create() and update(). This seems to fix the issue.

NB: Due to my current setup I am only able to test this on updating an existing issue, you probably want to verify that this still works for creating a new issue.