froger-me / wp-packages-update-server

WP Packages Update Server - Run Your Own Update Server for Plugins and Themes
GNU General Public License v3.0
140 stars 39 forks source link

Fatal Error on Activation #14

Closed oleteacher closed 5 years ago

oleteacher commented 5 years ago

I attempt to activate the plugin and get this message:

Plugin could not be activated because it triggered a fatal error. Failed to create the necessary database table(s).

I am using MAMP PRO4 (localhost), but have never had this happen in past years with any other plugin.

Maybe something I am missing? Simply uploaded / activated like any other plugin.

froger-me commented 5 years ago

Hi, On a fresh install of WordPress with MAMP Pro 4.5 on localhost, I could install the plugin successfully unfortunately without being able to reproduce the error. Is there more information that could help? Many other plugins don't typically create new tables in the database - does the issue also happen with installing, let's say, Simple Login Log?

oleteacher commented 5 years ago

Thanks for reply.

Yes, Simple Login Log installs without issue. I also tried a membership plugin that installs tables and it also activated without issue.

Holiday evening here so will have to get back on this tomorrow:)

froger-me commented 5 years ago

Thank you for the test and follow-up. As I wasn't able to confirm the issue on a similar (but likely not identical) environment, I'll stay put for more info ; basically, internally on plugin activation, there is a check for the existence of the table after doing a dbDelta (WordPress core function to compare and update database schema). If the result of the SHOW TABLES LIKE does not contain the newly created table's name, then the error is triggered.

$table_name = $wpdb->prefix . 'wppus_licenses';
$sql        = 'CREATE TABLE ' . $table_name . " (
        id int(12) NOT NULL auto_increment,
        license_key varchar(255) NOT NULL,
        max_allowed_domains int(12) NOT NULL,
        allowed_domains longtext NOT NULL,
        status ENUM('pending', 'activated', 'deactivated', 'blocked', 'expired') NOT NULL DEFAULT 'pending',         
        owner_name varchar(255) NOT NULL default '',
        email varchar(64) NOT NULL,
        company_name varchar(100) NOT NULL default '',
        txn_id varchar(64) NOT NULL default '',
        date_created date NOT NULL DEFAULT '0000-00-00',
        date_renewed date NOT NULL DEFAULT '0000-00-00',
        date_expiry date NOT NULL DEFAULT '0000-00-00',
        package_slug varchar(255) NOT NULL default '',
        package_type varchar(8) NOT NULL default '',
        PRIMARY KEY  (id),
        KEY licence_key (license_key)
        )" . $charset_collate . ';';

    dbDelta( $sql );

    $table_name = $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "wppus_licenses'" );

    if ( $wpdb->prefix . 'wppus_licenses' !== $table_name ) {
        return false;
    }

    return true;

Was any table containing the string wppus_licenses created in the database?

oleteacher commented 5 years ago

I am not sure what is going on. Looks like it will not work with MAMP Pro. Really do not want to install another server/software on my local machine, setup just like I like it:)

The table is created https://i.imgur.com/mWpmdMD.jpg

Have older laptop and will try the plugin on it using something like easyphp or another.

oleteacher commented 5 years ago

Just tried installing / activating on another virtual host within MAMP Pro and works!

The only difference are the database / table names. One that failed is like:

Database: wordpress_t »Table: twp_wppus_licenses

One that worked is like:

Database: wordpress »Table: wp_wppus_licenses

That is the only difference and I assume the issue.

oleteacher commented 5 years ago

Going to close this, as it doesn't really seem to be any fault of the plugin:)

I thank you very much for your input, help and sharing the plugin!

Susan