- π¬π§United Kingdom jamiep
Updated #11 to fix "Entity queries must explicitly set whether the query should be access checked or not" errors in Drupal 10
- First commit to issue fork.
- π¨π¦Canada bryden
I made a fork "3133989-retrieve-all-submissions-resource" which applies the patch from comment #13. I also made a small change:
Instead of returning the webform submission data, I return the entity and the data keyed respectively. Each sid is an array with [entity] and [data] keys so that you can access the webform subsmission entity, or the data (responses). This can be useful for instance if you need to access the uuid so that you can use one of the other resources to patch a particular submission, or to retrieve a file, etc., which wasn't available in the submission data array.
- Status changed to RTBC
12 months ago 7:21pm 6 February 2024 - Status changed to Needs work
12 months ago 9:15pm 6 February 2024 - Status changed to Needs review
12 months ago 6:12pm 8 February 2024 - π¨π¦Canada bryden
Contributing a patch based on the merge request so that these changes are available to developers using composer patches, until it gets merged.
- Assigned to tunic
- πͺπΈSpain tunic Madrid
The functionality provided by the MR is working ok for me. However, I think the timestamp parameter is not enough because you can't define a range.
I would like to replace it with an "after" and "before" params so you can define a time range.
- πͺπΈSpain tunic Madrid
Changes sent to the MR. I have changed more things that expected initially:
Improvements:
- Use StringTranslationTrait so $this->t() is used instead of t()
- If there were no submissions the previous code returned an error. However, REST APIs usually don't consider an empty set an error because the request is fine, it is just the data returned happens to be empty. Now the code returns just an empty set as result.
- Use HttpException for errors (like other plugins from this module). This simplifies error handling.
- Change output structure renaming webform_submissions to just submissions. The URL already indicates this is a webform and I think response should not leak implementation details to API consumers.
- Add parameters to define a time range ("after" and "before"). The timestamp parameter has been removed (or you could say it has been renamed because the "after" parameter works like the "timestamp" parameter) .
- Removed the check for the existence of the webform_id because this is taken care in upper layers (a 404 page is returned if no webform id is provided)
- Issue was unassigned.
- π«π·France mayeulk
Hi. I needed a short code to get all submissions, as a text-based backup (to be able to verify that submissions are correctly saved). I do this, with PostgreSQL:
pg_dump --dbname=postgresql://postgres@127.0.0.1:5432/postgres > /home/myself/backup/drupal_pg_backup.sql cat drupal_pg_backup.sql | grep ^my_second_webform_survey > results.csv
where 'my_second_webform_survey' is the URL name of the survey I need.
If you do not need the full sql backup, this works too:
pg_dump --dbname=postgresql://postgres@127.0.0.1:5432/postgres | grep ^my_second_webform_survey > results.csv
This gives the content of the public.webform_submission_data table (note there are other webform tables)
The headers are:
webform_id;sid;name;property;delta;value
Similarly, you could get some of the other tables; for instance, the public.webform_submission table has these fields:
sid,webform_id,uuid,langcode,serial,"token",uri,created,completed,changed,in_draft,current_page,remote_addr,uid,entity_type,entity_id,"locked",sticky,notes