• reinhardsanz

    (@reinhardsanz)


    Hey Everyone, Ive got a quick question. I am working on a plugin that extends core blocks with some custom attributes and saves some metadata in said attributes.

    Everything works fine and is saved to the DB as expected.
    If now the Plugin is deactivated (e.g. due to a PHP error) and a user edits the page, the previously saved metadata in the custom attributes is lost due to the attributes no longer existing.

    Is there any way to save and permanently (or atleast for a longer time) persist some custom data within a block? I want to avoid data accidently getting lost due to an PHP error.

Viewing 1 replies (of 1 total)
  • threadi

    (@threadi)

    I would recommend working with backups for this. If you save metadata, also save it in an option field. As soon as your plugin is reactivated, you can use this data to restore it to the post objects.

    However, I would recommend not to assume PHP errors across the board and then build such constructs. Rather make sure that your plugin does not cause such errors. You can’t do anything about what other plugins do. And every website operator should make backups anyway. If you don’t do it, you will lose such data.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.