Support » Plugins » $table_prefix error after WP 3.8.1 upgrade – plugins not working

  • Hi, I have two custom plugins that I built myself that are no longer working since the WP3.8.1 upgrade last week. Both show errors relating to $table_prefix. Each plugin is in its own version of WP-Multisite. Each Multisite network has its own database. (My host also updated from PHP v5.2 to 5.4 on the same day as WP auto-updated to 3.8.1 – I don’t know if this has caused any complications.)

    This is my code which is causing the errors:
    $db_table_to_access = $wpdb->$table_prefix.'db_table_to_access';

    These are the two errors:

    Notice: Undefined variable: table_prefix in /wp-content/plugins/myplugin/myplugin.php on line xxx
    Fatal error: Cannot access empty property in /wp-includes/wp-db.php on line 566

    Line 566 in wp-db.php is near the bottom of this excerpt:

    	 * PHP5 style magic getter, used to lazy-load expensive data.
    	 * @since 3.5.0
    	 * @param string $name The private member to get, and optionally process
    	 * @return mixed The private member
    	function __get( $name ) {
    		if ( 'col_info' == $name )
    		return $this->$name; //line 566 in /wp-includes/wp-db.php

    Any suggestions would be greatly appreciated!


Viewing 1 replies (of 1 total)
  • While I would still like to understand more about the errors reported, I did find a work-around that seems okay for now.

    My work-around:
    (1) in my plugin php files, changed $table_prefix to base_prefix in every instance.
    (2) in the databases, changed the table names to include the WordPress prefix as specified in the wp-config.php file (e.g. the default prefix is wp_)
    (3) in my plugin php files, updated all of the references to these tables throughout all my files.

    I still don’t understand why $table_prefix caused an error after WordPress 3.8.1 was installed. An explanation would be helpful. And any suggestions on how to refer to custom database tables in multisite plugins would be helpful to minimize time spent on such fixes.

Viewing 1 replies (of 1 total)
  • The topic ‘$table_prefix error after WP 3.8.1 upgrade – plugins not working’ is closed to new replies.