While trying to switch original language of a Commerce product type I've encountered longblob serialized data in config and key_value database tables.

Is there a quick way to edit them, possibly without writing a lot of PHP code?

  • 4
    If you're experienced and comfortable manually editing serialised PHP strings, then absolutely - otherwise you'll want to write PHP for this. It's hardly a lot of code, a few lines in a bootstrapped site is all you need. But manually editing the data isn't a good idea, you should ideally use the relevant APIs (which will also just be a few lines of PHP)
    – Clive
    Commented Nov 5, 2020 at 13:35
  • Thank you. I'll happily accept an explanation about how to find which APIs to use when editing something stored in these tables is not implemented yet, even the most general one. I agree that it's a bad idea to manually edit them but I just can't see any alternative in the aforementioned case unfortunately. Is it in database abstraction layer or maybe Entity API?
    – int_ua
    Commented Nov 5, 2020 at 13:55
  • 1
    It'll be at a higher level than database abstraction - but it depends what the config relates to. If you're changing entity config, then yeah that'll likely be the entity API
    – Clive
    Commented Nov 5, 2020 at 13:57

2 Answers 2


Don't edit the serialized config, edit the config as YAML. Try for example

drush cedit

See other options (UI and command line) here: https://www.drupal.org/docs/configuration-management

  • I'll accept this for now, but I can't verify it myself as I'm trying to make it work without Drush. I have nothing against it, I used it very extensively in the past, just an experiment with the new bin/drupal CLI.
    – int_ua
    Commented Nov 5, 2020 at 15:08
  • 1
    The drush command is just a more efficient way of what you can do in UI by exporting a config YAML file, modifying and importing it again.
    – 4uk4
    Commented Nov 5, 2020 at 15:12
  • I've discovered more similar instances, installed drush and verified that it's working, thank you.
    – int_ua
    Commented Nov 16, 2020 at 14:36

Export-import way

(added as a later edit)

It's possible that the values you need can be exported at


Then edited and re-imported at


SQL way

Do not try it unless you can afford losing your database and you really understand what you are doing.

I've managed to edit it by using these SQL commands:

select hex('serialized string that you got with CAST(data as CHAR) here');
UPDATE `drupal_config` SET data=0xHEXVALUEFROMPREVIOUSSTEP WHERE name="commerce_product.commerce_product_type.yourproducttypemachinename";

The SQL does not expect there to be any translated values, select with WHERE name="commerce_product.commerce_product_type.yourproducttypemachinename" should return only one row.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.