View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
05035Bug reportsInstallationpublic2011-05-04 19:31
Reporteruser12801Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Fixed in Version1.91 
Summary05035: GSOC: main page reports generic database error if initial tables do not exist
Description

After initial setup and editing the config.php, if the user visits the root application page instead of the admin page, they see an unhelpful database error message.

A careful installer would not fall into this trap but I was in a rush and instead spent a lot of time trying to sort out what was not a database connection problem at all.

Steps To Reproduce
  • perform installation steps through the end of section 5 in the installation docs
  • visit the root application page
  • see error message that causes you to look at your DB connection info in config.php and become confused
Additional Information

The simple fix might be more detail in the error message to clue a new user in.

More complex would be detection of the partially configured state taking some sensible action based on that (maybe redirect to admin page).

TagsNo tags attached.
Attached Files
cleared.patch (838 bytes)   
--- C:\Users\3ncrypt3d\Desktop\bugs\index.php	2011-03-29 05:53:57.230468700 +0530
+++ C:\Users\3ncrypt3d\Desktop\bugs\index1.php	2011-03-29 05:01:53.149414000 +0530
@@ -395,7 +395,9 @@
 			  AND ((a.expires >= '".date("Y-m-d H:i")."') OR (a.expires is null))
               AND ((a.startdate <= '".date("Y-m-d H:i")."') OR (a.startdate is null))
 			  ORDER BY surveyls_title";
-    $result = db_execute_assoc($query,false,true) or die("Could not connect to database. If you try to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage."); //Checked
+    if($result = db_execute_assoc($query,false,true)){} 
+	else
+	header("Location:./admin/install");//Checked
     $list=array();
     if($result->RecordCount() > 0)
     {
cleared.patch (838 bytes)   
modified.patch (775 bytes)   
398c398
<     $result = db_execute_assoc($query,false,true) or die("Could not connect to database. Trying to install Limesurvey? please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage."); //Checked
---
>     $result = db_execute_assoc($query,false,true) or die("Could not connect to database. If you are trying to install Limesurvey please refer to the <a href='http://docs.limesurvey.org/Installation&structure=English+Instructions+for+LimeSurvey#Run_the_installation_script'>installation docs</a>(in english) for this specific issue, for other languages check <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage."); //Checked
modified.patch (775 bytes)   
index.diff (851 bytes)   
--- C:/Users/Admin/AppData/Local/Temp/index.php-revBASE.svn000.tmp.php	Fri Apr  8 09:44:53 2011
+++ C:/wamp/www/LS-stable/index.php	Fri Apr  8 09:40:55 2011
@@ -30,7 +30,16 @@
 $move=sanitize_paranoid_string(returnglobal('move'));
 $clienttoken=sanitize_token(returnglobal('token'));
 
+if (!$database_exists)
+{
+die("Unable to connect to database.<br />If you are trying to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage.");
+}
 
+if ($dbexistsbutempty)
+{
+die("No tables in database.<br />If you are trying to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage.");
+}
+
 if (!isset($thisstep))
 {
     $thisstep = "";
index.diff (851 bytes)   
05035_dev.patch (1,374 bytes)   
Index: common.php
===================================================================
--- common.php	(revision 9939)
+++ common.php	(working copy)
@@ -143,6 +143,11 @@
     $captchapath=$rooturl.'/';  
 }
 
+//check if databasename is set in config file
+if (!$databasename)
+{
+    die("Database Information not provided. If you try to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage.");
+}
 
 //BEFORE SESSIONCONTOL BECAUSE OF THE CONNECTION
 //CACHE DATA
@@ -223,8 +228,13 @@
 }
 
 
-// Check if the DB is up to date
-If ($dbexistsbutempty && $sourcefrom=='admin') {
+//check if database exist and access is not via install script
+if (!$database_exists && (strcasecmp($slashlesspath,str_replace(array("\\", "/"), "", $homedir."install")) != 0)) {
+    die ("<br/>The LimeSurvey database does not exist. Please run the <a href='$homeurl/install/index.php'>install script</a> to create the necessary database.");
+}
+ 
+ // Check if the DB is up to date
+if ($dbexistsbutempty && (strcasecmp($slashlesspath,str_replace(array("\\", "/"), "", $homedir."install")) != 0)) {
     die ("<br />The LimeSurvey database does exist but it seems to be empty. Please run the <a href='$homeurl/install/index.php'>install script</a> to create the necessary tables.");
 }
 
05035_dev.patch (1,374 bytes)   
Bug heat10
Complete LimeSurvey version number (& build)9642
I will donate to the project if issue is resolvedNo
Browser
Database type & versionpostgres 8.4
Server OS (if known)Debian Lenny
Webserver software & version (if known)Apache2
PHP Version5

Users monitoring this issue

There are no users monitoring this issue.

Activities

Mazi

Mazi

2011-03-21 00:45

updater   ~14486

Can you test if this problem shows up with postgres only? I think is is no problem when using MySQL?!

user12801

2011-03-21 00:52

  ~14489

One of the paths I went down was switching to mysql to see if that made a difference and it didn't seem to.

This is from memory though so I might be incorrect. I'll try to reproduce that when I get some time.

user13064

2011-03-29 02:29

  ~14591

Hi,

I am very much interested in taking part in GSoC 2011 for limesurvey. This is my first contribution towards opensource. This patch takes care of the problem as far as i have checked. Let me know if there are any suggestions to improve it.

Thanks.

Mazi

Mazi

2011-03-29 13:48

updater   ~14595

Carsten, can you please review the patch and give some feedback?

Thanks for providing your patch, murarivivek. You can list this ticket as a reference at your application.

c_schmitz

c_schmitz

2011-03-29 19:52

administrator   ~14605

The patch does not take care of the fact that the admin directory could be renamed (check config-defaults.php for the according setting).
Also I think that an auto-transfer to the admin installation is not the ideal solution. We don't want any user stumbling on the root of the LimeSurvey dir run the installation.

What should be changed is that there is an an error message that makes more sense in this particular case, maybe hints for the documentation without providing a direct link.

user13064

2011-03-30 02:00

  ~14616

So, does it mean making changes to the error message adding a better description and hints will do?

c_schmitz

c_schmitz

2011-03-30 10:00

administrator   ~14617

Yes :-)

user13064

2011-03-30 17:05

  ~14620

changed the error message with better description for this specific issue.

c_schmitz

c_schmitz

2011-04-04 13:39

administrator   ~14651

murarivivek, that patch is bogus and the error message is still wrong. You did not test what happens under certain conditions. You should test what the error message is under the following conditions:

  • no database
  • empty database

and provide according error messages with hints to the documentation

For example 'Could not connect to database.' is shown even though the database exists - which is obivously irritating. Also please provide a subversion patch instead (svn -diff) vs. the stable branch. Thank you!

user13313

2011-04-08 17:53

  ~14737

I'm also trying to complete a last-minute application for GSOC.

I believe the attached patch will solve the problem, although perhaps a better long-term solution would be to address the issue in common.php where the database errors are shown in admin mode:

Line 226:
// Check if the DB is up to date
If ($dbexistsbutempty && $sourcefrom=='admin') {
die ("<br />The LimeSurvey database does exist but it seems to be empty. Please run the <a href='$homeurl/install/index.php'>install script</a> to create the necessary tables.");
}

c_schmitz

c_schmitz

2011-04-11 14:10

administrator   ~14780

Thank you, magiclko.

Issue History

Date Modified Username Field Change
2011-03-16 02:05 user12801 New Issue
2011-03-21 00:45 Mazi Note Added: 14486
2011-03-21 00:45 Mazi Assigned To => c_schmitz
2011-03-21 00:45 Mazi Status new => feedback
2011-03-21 00:52 user12801 Note Added: 14489
2011-03-21 00:52 user12801 Status feedback => assigned
2011-03-26 17:50 Mazi Summary main page reports generic database error if initial tables do not exist => GSOC: main page reports generic database error if initial tables do not exist
2011-03-29 02:23 user13064 File Added: cleared.patch
2011-03-29 02:29 user13064 Note Added: 14591
2011-03-29 02:29 user13064 Issue Monitored: user13064
2011-03-29 13:48 Mazi Note Added: 14595
2011-03-29 19:52 c_schmitz Note Added: 14605
2011-03-30 02:00 user13064 Note Added: 14616
2011-03-30 10:00 c_schmitz Note Added: 14617
2011-03-30 17:04 user13064 File Added: modified.patch
2011-03-30 17:05 user13064 Note Added: 14620
2011-04-04 13:39 c_schmitz Note Added: 14651
2011-04-04 13:39 c_schmitz Status assigned => feedback
2011-04-08 17:50 user13313 File Added: index.diff
2011-04-08 17:53 user13313 Note Added: 14737
2011-04-10 11:16 magiclko File Added: 05035_dev.patch
2011-04-11 14:10 c_schmitz Note Added: 14780
2011-04-11 14:10 c_schmitz Status feedback => resolved
2011-04-11 14:10 c_schmitz Fixed in Version => 1.91
2011-04-11 14:10 c_schmitz Resolution open => fixed
2011-05-04 19:31 c_schmitz Status resolved => closed