• Resolved therealgilles

    (@chamois_blanc)


    Hello,

    I just updated to v2.0.1 and I am getting lots of database errors. Something is very wrong. Please advise/fix. Thank you!

    [15-Dec-2017 02:55:56 UTC] WordPress database error Table 'dnvxwyxfcy.wp_sm_sessions' doesn't exist for query SELECT * FROM wp_sm_sessions WHERE session_key = '8c880999466a5f1670e1e87b2b4c70f1' made by require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('plugins_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, wp_session_start, WP_Session::get_instance, WP_Session->__construct, WP_Session->read_data, WP_Session_Utils::get_session
    [15-Dec-2017 02:55:56 UTC] WordPress database error Table 'dnvxwyxfcy.wp_sm_sessions' doesn't exist for query SELECT * FROM wp_sm_sessions WHERE session_key = '8c880999466a5f1670e1e87b2b4c70f1' made by require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('plugins_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, wp_session_start, WP_Session::get_instance, WP_Session->__construct, WP_Session->read_data, WP_Session_Utils::get_session
    [15-Dec-2017 02:55:58 UTC] WordPress database error Table 'wp_sm_sessions' already exists for query CREATE TABLE wp_sm_sessions (
                      session_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
                      session_key char(32) NOT NULL,
                      session_value LONGTEXT NOT NULL,
                      session_expiry BIGINT(20) UNSIGNED NOT NULL,
                      PRIMARY KEY  (session_key),
                      UNIQUE KEY session_id (session_id)
                    ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci made by do_action('admin_init'), WP_Hook->do_action, WP_Hook->apply_filters, create_sm_sessions_table, dbDelta
Viewing 8 replies - 1 through 8 (of 8 total)
  • It means that you don’t have permissions to create new tables. Add this line to your wp-config.php file

    define( 'WP_SESSION_USE_OPTIONS', true );

    This is documented here

    https://github.com/ericmann/wp-session-manager

    Plugin Author Eric Mann

    (@ericmann)

    The database creation routine wasn’t wired correctly to run <i>before</i> session initialization as of v2.0.1. That specific bug was fixed in v2.0.2. This should be resolved now with either that or the latest 3.X versions.

    Alternatively, Andrew’s suggestion to <i>force</i> options usage will skip working with a custom database table entirely. Either way, this should be resolved.

    Please advise if that’s not the case.

    Thread Starter therealgilles

    (@chamois_blanc)

    Hi Eric,

    I have updated to v3.* and it seems to work fine. Note that I had to remove ‘define(WP_SESSION_USE_OPTIONS, true)’ from wp-config.php to things to work. That should maybe be mentioned somewhere in the documentation.

    Thread Starter therealgilles

    (@chamois_blanc)

    It looks like the code to start a session should be conditioned on $_SESSION not being already set, something like this:

    function my_session_start() {
      if (!isset($_SESSION)) {
        session_start();
      }
    }
    
    // Start up session management, if we're not in the CLI
    if (!defined('WP_CLI') || false === WP_CLI) {
        add_action('plugins_loaded', 'my_session_start', 10, 0);
    }
    • This reply was modified 7 years, 2 months ago by therealgilles.
    Plugin Author Eric Mann

    (@ericmann)

    The session_start() call will either start a new session or resume an existing one. Without that call, $_SESSION won’t be populated at all. See https://php.net/manual/en/function.session-start.php for reference.

    Thread Starter therealgilles

    (@chamois_blanc)

    I am getting a PHP notice because session_start() is being called when the session is already active. It is possible the session was started by some other plugin. That is why I am advocating to check whether the session was already started before calling session_start().

    Plugin Author Eric Mann

    (@ericmann)

    I’m super curious what other code is calling session_start(), but that’s beside the point.

    I added some more defensive coding in v3.0.3 (just released) that checks to see if the session is active before calling session_start(). If it’s already been started by some other code, then I won’t run a duplicate call.

    Thread Starter therealgilles

    (@chamois_blanc)

    Here are some answers for you:

    			session_start();
    wp-content/plugins/woo-order-export-lite/classes/core/class-wc-order-export-engine.php
          session_start();
    wp-content/plugins/upme/modules/social/lib/facebook/facebook.php
    		session_start();
    wp-content/plugins/upme/modules/social/class-upme-facebook-connect.php
    		@session_start();
    wp-content/plugins/upme/modules/social/class-upme-linkedin-connect.php
            @session_start();
    wp-content/plugins/upme/modules/social/class-upme-google-connect.php
    		@session_start();		
    wp-content/plugins/upme/modules/social/class-upme-twitter-connect.php
                session_start();
                    session_start();
    wp-content/plugins/updraftplus/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php

    Thank you for making the change!

    • This reply was modified 7 years, 2 months ago by therealgilles.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WP Session creates database error’ is closed to new replies.