Page 1 of 1

Can't open sqlite DB in shared 2.0 fresh install...

Posted: Tue Aug 26, 2014 9:21 am
by latcarf
Hi all,

I tried a fresh "shared" installation of 2.0 with sqlite tonight and after setup, clicking "Visit your new blog here" got the following error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [14] unable to open database file' in /usr/local/lib/php/serendipity2/s9y/include/db/pdo-sqlite.inc.php:105 Stack trace: #0 /usr/local/lib/php/serendipity2/s9y/include/db/pdo-sqlite.inc.php(105): PDO->__construct('sqlite:/usr/loc...') #1 /usr/local/lib/php/serendipity2/s9y/serendipity_config.inc.php(295): serendipity_db_connect() #2 /home/me/serendipity/serendipity_config.inc.php(8): require_once('/usr/local/lib/...') #3 /usr/local/lib/php/serendipity2/s9y/index.php(23): include('/home/me/serend...') #4 /home/me/serendipity/index.php(6): require_once('/usr/local/lib/...') #5 {main} thrown in /usr/local/lib/php/serendipity2/s9y/include/db/pdo-sqlite.inc.php on line 105

My open_basedir is:
"/tmp:/usr/local/lib/php/:/usr/local/lib/php/serendipity2/s9y/:/home/me/serendipity/"

DB file is created OK and listed correctly in serendipity_config_local.inc.php.

https user ("apache") has write access to both the db and the main directory (verified since it created the db OK).

Any thoughts...?

Re: Can't open sqlite DB in shared 2.0 fresh install...

Posted: Tue Aug 26, 2014 10:24 am
by Timbalu
just guessing..., this is while the db resides in open_basedir path, but Serendipity path is in /home/..

Try with /include/db/pdo-sqlite.inc.php(105)

As a one-liner before:

Code: Select all

$serendipity['dbConn'] = new PDO('sqlite:' . $serendipity['serendipityPath'] . $serendipity['dbName'] . '.db');
and then:

Code: Select all

$serendipity['dbConn'] = new PDO('sqlite:' . $serendipity['dbName'] . '.db');
What does it do?

Re: Can't open sqlite DB in shared 2.0 fresh install...

Posted: Tue Aug 26, 2014 8:39 pm
by latcarf
Thanks Timbalu! That fixes the problem but I don't fully understand why...

Serendipity is installed in /usr/local/lib/php/serendipity2/s9y since it's a shared installation but the database is created (by default) in /home/me/serendipity/. The open_basedir contains "/home/me/serendipity/."

Your fix seems to indicate that $serendipity['serendipityPath'] is "/usr/local/lib/php/serendipity2/s9y" in the shared install case. Is that true?

So, my other question is, how can I accomplish this fix without having to patch /include/db/pdo-sqlite.inc.php(105)?

Thanks for your help fixing it in the first place!!

Re: Can't open sqlite DB in shared 2.0 fresh install...

Posted: Wed Aug 27, 2014 6:15 pm
by Timbalu
latcarf wrote:Your fix seems to indicate that $serendipity['serendipityPath'] is "/usr/local/lib/php/serendipity2/s9y" in the shared install case. Is that true?
I don't know. What does the Configuration - Path - Full Path option field say?
latcarf wrote:So, my other question is, how can I accomplish this fix without having to patch /include/db/pdo-sqlite.inc.php(105)?
It depend on how this should work. Maybe the local db install in /home is totally OK, since a shared installation having each users its own database. So maybe we need to reset the sqlite $serendipity['serendipityPath'] for shared installs.

I think we will have to wait for Garvin showing up, to give some concrete suggestions on what to do here.

Edit: I had some more thoughts on this ... maybe you should write for shared installs

Code: Select all

$serendipity['dbConn'] = new PDO('sqlite:' . S9Y_DATA_PATH . $serendipity['dbName'] . '.db');
instead. Give it a try.

Re: Can't open sqlite DB in shared 2.0 fresh install...

Posted: Tue Sep 09, 2014 1:18 pm
by garvinhicking
Great find. Fixed here: https://github.com/s9y/Serendipity/issu ... t-54944875

Thanks,
Garvin

Re: Can't open sqlite DB in shared 2.0 fresh install...

Posted: Wed Sep 10, 2014 7:14 am
by latcarf
Fixed here: https://github.com/s9y/Serendipity/issu ... t-54944875
Awesome! Thanks.