Ticket #1254 (closed defect: worksforme)

Opened 18 months ago

Last modified 17 months ago

Installer fails when installing to Sqlite on PHP 5.2.12

Reported by: lildude Owned by:
Priority: blocker Milestone: 0.7
Component: Habari Core Software Version: SVN
Keywords: Cc:

Description

The installer has problems creating and then accessing the database file and the resulting PDO errors are hidden from view.

Using Firebug, I was able to obtain the following error that is returned when clicking the "Check Database Connection" button:

<pre class="error">
<b>PDOException:</b> SQLSTATE[HY000] [14] unable to open database file in /home/cs125667/public_html/testhb/system/classes/databaseconnection.php line 112
</pre>

It doesn't tell us much, but the corresponding Apache logs (with xdebug enabled and superfluous information removed) does give more useful information, depending on whether the file exists or not:

NO habari.db file:

PHP Fatal error:  Call to a member function prepare() on a non-object in /home/lildude/public_html/testhb/system/classes/databaseconnection.php on line 243, referer: http://example.com/~lildude/testhb/
PHP Stack trace:, referer: http://example.com/~lildude/testhb/
PHP   1. Error::exception_handler($exception = class PDOException { protected $message = 'SQLSTATE[HY000] [14] unable to open database file'; private $string = ''; protected $code = 0; protected $file = '/home/lildude/public_html/testhb/system/classes/databaseconnection.php'; protected $line = 112; private $trace = array (0 => array (...), 1 => array (...), 2 => array (...), 3 => array (...), 4 => array (...), 5 => array (...), 6 => array (...), 7 => array (...), 8 => array (...), 9 => array (...)); public $errorInfo = NULL }) /home/lildude/public_html/testhb/system/classes/error.php:0, referer: http://example.com/~lildude/testhb/
PHP   2. Options::get($name = 'log_backtraces') /home/lildude/public_html/testhb/system/classes/error.php:60, referer: http://example.com/~lildude/testhb/
PHP   3. Options->__get($name = 'log_backtraces') /home/lildude/public_html/testhb/system/classes/options.php:0, referer: http://example.com/~lildude/testhb/
PHP   4. Options->get_all_options() /home/lildude/public_html/testhb/system/classes/options.php:115, referer: http://example.com/~lildude/testhb/
PHP   5. DB::get_results($query = 'SELECT name, value, type FROM {options}', $args = array (), 'QueryRecord') /home/lildude/public_html/testhb/system/classes/options.php:132, referer: http://example.com/~lildude/testhb/
PHP   6. DatabaseConnection->get_results($query = 'SELECT name, value, type FROM {options}', $args = array (), 'QueryRecord') /home/lildude/public_html/testhb/system/classes/db.php:245, referer: http://example.com/~lildude/testhb/
PHP   7. DatabaseConnection->query($query = 'SELECT name, value, type FROM {options}', $args = array ()) /home/lildude/public_html/testhb/system/classes/databaseconnection.php:457, referer: http://example.com/~lildude/testhb/

Pre-created habari.db file, with correct permissions:

PHP Fatal error:  Call to a member function prepare() on a non-object in /home/lildude/public_html/testhb/system/classes/databaseconnection.php on line 243, referer: http://example.com/~lildude/testhb/
PHP Stack trace:, referer: http://example.com/~lildude/testhb/
PHP   1. Error::exception_handler($exception = class PDOException { protected $message = 'SQLSTATE[HY000] [14] unable to open database file'; private $string = ''; protected $code = 0; protected $file = '/home/lildude/public_html/testhb/system/classes/databaseconnection.php'; protected $line = 112; private $trace = array (0 => array (...), 1 => array (...), 2 => array (...), 3 => array (...), 4 => array (...), 5 => array (...), 6 => array (...), 7 => array (...), 8 => array (...), 9 => array (...)); public $errorInfo = NULL }) /home/lildude/public_html/testhb/system/classes/error.php:0, referer: http://example.com/~lildude/testhb/
PHP   2. Options::get($name = 'log_backtraces') /home/lildude/public_html/testhb/system/classes/error.php:60, referer: http://example.com/~lildude/testhb/
PHP   3. Options->__get($name = 'log_backtraces') /home/lildude/public_html/testhb/system/classes/options.php:0, referer: http://example.com/~lildude/testhb/
PHP   4. Options->get_all_options() /home/lildude/public_html/testhb/system/classes/options.php:115, referer: http://example.com/~lildude/testhb/
PHP   5. DB::get_results($query = 'SELECT name, value, type FROM {options}', $args = array (), 'QueryRecord') /home/lildude/public_html/testhb/system/classes/options.php:132, referer: http://example.com/~lildude/testhb/
PHP   6. DatabaseConnection->get_results($query = 'SELECT name, value, type FROM {options}', $args = array (), 'QueryRecord') /home/lildude/public_html/testhb/system/classes/db.php:245, referer: http://example.com/~lildude/testhb/
PHP   7. DatabaseConnection->query($query = 'SELECT name, value, type FROM {options}', $args = array ()) /home/lildude/public_html/testhb/system/classes/databaseconnection.php:457, referer: http://example.com/~lildude/testhb/

(I've deliberately NOT wrapped the lines above as it makes them harder to read).

MySQL installation works as expected. I've not tested PgSQL

This issue doesn't occur with PHP 5.3.2 so I think we may be looking at another case of PHP 5.2.12's PDO bad constructor behaviour.

Change History

comment:1 Changed 18 months ago by lildude

After a bit of investigating and this seems to be a problem with using a relative path to the DB file instead of an absolute path.

Changing line system/classes/installhandler.php#L1789 of to:

$db_file = HABARI_PATH . '/' . Site::get_path( 'user', TRUE ) . $db_file;

Solves the problem and doesn't seem to break things on other PHP releases.

Will need to do more testing before committing this change.

comment:2 Changed 17 months ago by rickc

Would substituting Site::get_path( 'user', TRUE ) with Site::get_dir( 'user', TRUE ) be adequate? Site::get_dir() is supposed to return a full file system path.

comment:3 Changed 17 months ago by lildude

  • Status changed from new to closed
  • Resolution set to worksforme

Hmmm, this problem no longer occurs for some reason. A clean install of r4308 now works a treat.

Closing this ticket as "works for me" as I was the one who logged the ticket and no one else has reported the problem.

If anyone else encounters this issue, please feel free to re-open this ticket.

Note: See TracTickets for help on using tickets.