Support » Plugin: 301 Redirects - Easy Redirect Manager » Database error on multisite

  • Resolved Schweizer Solutions GmbH



    on the multisite we become an database error in the log, because the table is not created for the specific blog id:

    [error] 24820#24820: *51548 FastCGI sent in stderr: "PHP message: WordPress-Datenbank-Fehler Table 'db.wp_93_redirects' doesn't exist für Abfrage SELECT *
                FROM wp_93_redirects
                WHERE status != 404 AND status != 'inactive'
                ORDER BY id desc von require('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, EPS_Redirects->do_redirect, EPS_Redirects::get_redirects" while reading response header from upstream, client:, server:, request: "POST /wp-login.php HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-fpm.db.sock:", host: "", referrer: ""

    We’ve changed the create table function, to support multisite installation:

    	public static function _create_redirect_table() {
    		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    		global $wpdb;
    		$blogids = array( false );
    		if ( is_network_admin() && is_multisite() ) {
    			$old_blog = $wpdb->blogid;
    			$blogids  = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
    		foreach ( $blogids as $blog_id ) {
    			if ( $blog_id ) {
    				switch_to_blog( $blog_id );
    			$table_name = $wpdb->prefix . "redirects";
    			$sql = "CREATE TABLE $table_name (
              id mediumint(9) NOT NULL AUTO_INCREMENT,
              url_from VARCHAR(256) DEFAULT '' NOT NULL,
              url_to VARCHAR(256) DEFAULT '' NOT NULL,
              status VARCHAR(12) DEFAULT '301' NOT NULL,
              type VARCHAR(12) DEFAULT 'url' NOT NULL,
              count mediumint(9) DEFAULT 0 NOT NULL,
              UNIQUE KEY id (id)
    			dbDelta( $sql );
    		if ( $blog_id ) {
    			switch_to_blog( $old_blog );

    It will be nice, if you can add multisite support to your next update.

    Another thing is, that this plugin don’t have a uninstall.php, where the table(s) will be dropped, if we uninstall it. Maybe you can fix this also 😉


  • The topic ‘Database error on multisite’ is closed to new replies.