Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Database table does not exist error in Multisite if first Network Activated #13

@knutsp

Description

@knutsp

If this plugin is Network Activated only (not per site) the first time, the table "cloud_blocks" is not created when a site is accessed (and this plugin loaded).

WordPress database error Table 'mydbname.myprefix_3_cloud_blocks' doesn't exist for query SELECT * FROM nytt_3_cloud_blocks made by require('wp-blog-header.php')[,...,] WP_Hook->apply_filters, CloudBlocks\Blocks\Blocks->blocks_register_styles, CloudBlocks\Blocks\Options::get_all

This because the custom table creation is only called at plugin activation.

For a plugin, that creates persistent changes like this, to be network (Multisite) ready , it must check that it's installed upon loading (at least admin_init) by an option or directly checking existence of the resource (table). If not, run the installer on that site to create the tables.

Looping through sites at activation is not recommended as it dosn't take are of new sites added later.

I suggest get_option( 'cloud_blocks_installed' ) or similar in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions