Guides & Tutorials7.7 Update TroubleshootingTroubleshooting Duplicate entry Local Storage Errors

Troubleshooting Duplicate entry Local Storage Errors


When applying the WHMCS 7.7.0 update, the following SQL error may occur:

	SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Local Storage: /var/www/vhosts/...' for key 'name' (SQL: insert into tblstorageconfigurations(is_local, name, handler, settings, sort_order, updated_at, created_at)  values (1, Local Storage: /var/www/vhosts/.../whmcs/downloads,  WHMCS\File\Provider\LocalStorageProvider,  {"local_path":"\/var\/www\/vhosts\/...\/whmcs\/downloads"}, 4,  2019-01-24 09:05:27, 2019-01-24 09:05:27))


This occurs when the folder locations specified in the configuration.php file are invalid or duplicated.


Open the configuration.php file in the WHMCS root directory and observe the directory lines. They should look something like this:

$attachments_dir = "/home/username/attachments/";
$downloads_dir = "/home/username/downloads/";
$templates_compiledir = "/home/username/templates_c/";
  1. Ensure that these file locations exist on your server. If they do not, the folders should be created or the configuration.php file updated with the valid directory location.
  2. Remove any duplicate $attachments_dir, $downloads_dir and $templates_compiledir entries. Only one of each should be present.

Below are examples of problematic configuration.php files:

Duplicate $attachments_dir entry
$downloads_dir location doesn't exist on server


1. Make the necessary correction to the configuration.php file. An example of a valid file is shown below:

Example valid configuration.php

2. Clear the contents of the local storage setting table with the following SQL command:

TRUNCATE TABLE tblstorageconfigurations;
TRUNCATE TABLE tblfileassetsettings;

3. Run the database update to 7.7.0 a second time by visiting /install/install.php

This time the error will not occur.