Local Community

Local 5.10.1 duplicated database entries

Issue Summary

When creating custom $wpdb table and custom entries (with wp functions) local creates duplicated entries while it should create only one. For example $wpdb->insert(…);
It only happens on local. Tested on XAMPP and this behaviour does’t happen (both local/xampp ssl https).

Tested with empty theme (only empty style.css, empty functions.php, empty index.php) No plugins installed, brand new site and database.

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular? All.

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser? Yes.


Create these 2 functions in functions.php. (first to create a table, second to create an entry).
It should creat 1 entry to that table on each page reload. But instead it creates 2 entries in the table.

function create_table($table_name){
    global $wpdb;

    $charset_collate = $wpdb->get_charset_collate();
    $table_name = $wpdb->prefix . $table_name;

    $sql = "CREATE TABLE $table_name (
    user_name varchar(100) DEFAULT '' NOT NULL,
    password varchar(100) DEFAULT '' NOT NULL,
    email varchar(100) DEFAULT '' NOT NULL,
    PRIMARY KEY  (id)
    ) $charset_collate;";

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );


function insert_to_table($table_name){
    global $wpdb;

    $table_name = $wpdb->prefix . $table_name;

            'user_name' => 'user', 
            'password' => 'pass', 
            'email' => 'myemail',


System Details

  • Which version of Local is being used? local 5.10.1

  • What Operating System (OS) and OS version is being used? Mac OS 11.2.2 & 10.15.7

    • For example: macOS Catalina or Windows 10 Professional
  • Attach the Local Log. See this Community Forum post for instructions on how to do so:

@clay any help to confirm it’s a Local bug? Or that’s something wrong with my configuration?

Meanwhile have to go back to XAMPP.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.