0

We recently had a security breach and those making the decision opted to remove the capability of end users to create the file upload component.

What I am hoping to do is two-fold:

1.) Use drush sql-query to iterate through all our databases and return all webforms using the file upload component. Optimally this output would need to be sent to a .txt file or something similar so that we know which webforms to address and which sites were using it.

I am hoping to use sql-query with a SELECT statement to look at the webform_component table to get this data so that we can take action.

I know how to drush simple things to a text file, on each database directly (drush @cms.name_of_database site-alias >all.txt), and I know how to use drush sql-query to UPDATE but I do not know how to iterate through each of our databases and then output the results of the query into a single .txt file.

2.) Use Drush to disable the file component (Configuration > Content Authoring > Webform Settings) to uncheck the file component.

We have about 300 sites so we are really hoping we can avoid having to manually configure this across all 300 databases/sites.

Note: I am not trying to export/import content types, I am trying to query our databases via drush and output the results into a .csv or other file type. My second issues is that I need to iterate that script across all 300 databases we have and output the results to either a single file or a file for each db

9
  • That's a task for the Features module as outlined in some of the answers in the other question. Create Webform on one instance, export to feature module, enable/import feature module on all other instances, and finally export all instances config. Use Features to sync particular config and/or bundles across all instances during development and in the end you still export every instance's config on their own. Drush at hand. – leymannx Dec 2 '20 at 10:25
  • @leymannx - This doesn't really answer my question. I am not trying to export/import content types, I am trying to query our databases via drush and output the results into a .csv or other file type. My second issues is that I need to iterate that script across all 300 databases we have and output the results to either a single file or a file for each db. – user101734 Dec 2 '20 at 16:50
  • 1
    Have you considered Forena to create those CSV files? – Pierre.Vriens Dec 2 '20 at 17:28
  • 1
    This should be a simple bash script - drush sa to list the aliases, refine if needed, then loop over and run a drush command for each to gather data – Clive Dec 2 '20 at 17:43
  • 2
    UPDATE: I was able to figure out how to append the results to a single file with the following using "@"sites: drush @sites sql-query "SELECT nid FROM webform_component WHERE type = 'file'" >> /path/to/directory/file-components.tsv -y -v; Thanks for everyone's help! – user101734 Dec 2 '20 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.