Add Widget button not working after migration from version 6.5 to version 7.0.1 if user with id 1 is not enabled
If you perform an upgrade from 6.5 to 7.0.1 and the original admin user (id 1) was previously disabled or deleted, then the table vtiger_module_dashboard_widgets
does not get updated with the new column dashboardtabid
. If that column does not exist, then widgets in the home page won't work. No widgets are shown and the Add Widget button is disabled.
That happens because of the following lines on the migration script in the file 660_to_700.php
:
$result = $db->pquery('SELECT id FROM vtiger_dashboard_tabs WHERE userid=? AND tabname=?', array(1, 'Default'));
$defaultTabid = $db->query_result($result, 0, 'id');
//Setting admin user default tabid to DEFAULT
$db->pquery("ALTER TABLE vtiger_module_dashboard_widgets ADD COLUMN dashboardtabid INT(11) DEFAULT $defaultTabid", array());
As you can see, the first query takes for granted that there is an entry in vtiger_dashboard_tabs
for user id 1. Which is not the case if that user is disabled or deleted.
I think there are 3 possible solutions:
- Not permitting to perform an update if the user with id 1 is not enabled.
- Disabling the deletion or disabling of user with id 1.
- Eliminating dependencies with user id 1 in migration scripts.