wordpress-owncloud-integration
wordpress-owncloud-integration copied to clipboard
sync_to_oc ($attachmentId) creates invalid attachment meta
public function sync_to_oc ($attachmentId) {
function breaks attachment postmeta in wordpress,
$response['headers']['etag']
is an array and the resulting hidden field in the media panel has an error (notice) due to array to string conversion
Notice: Array to string conversion in wp-includes/formatting.php on line 1045
Currently stored metadata looks (serialized) like a:1:{i:0;s:34:""679d66293996de7d55b3c1492c3a655c"";}
This get passed (internally) via esc_attr, which expects a string.
My current fix suggestion is to add an array check:
Replace
update_post_meta( $attachmentId, 'oc_etag', $response['headers']['etag'] );
With:
update_post_meta( $attachmentId, 'oc_etag', is_array($response['headers']['etag']) ? $response['headers']['etag'][0] : $response['headers']['etag'] );