cakephp / datasources

CakePHP Datasources
http://cakephp.org
237 stars 114 forks source link

Invalid database configuration results in fatal error #75

Closed ghost closed 10 years ago

ghost commented 11 years ago

Created by Daniel, 26th Mar 2012. (originally Lighthouse ticket #33):


An invalid database configuration can sometimes result in a failure to connect to the SQLite database without an error. As no error is caught by CakePhP, PhP itself throws a fatal error on line 221 as no $connection object exists. This bug fix forces the _execute() function to check that the database is in fact connected - if not, CakePhP gracefully throws a helpful error message to the user.

Reported here: http://stackoverflow.com/questions/4779007/cakephp-and-sqlite-fatal-error-call-to-a-member-function-query-on-a-non-obje, here: http://stackoverflow.com/questions/7107996/fatal-error-call-to-a-member-function-query-on-a-non-object-in-var-www-likes, and here: http://stackoverflow.com/questions/7572091/error-while-trying-to-connect-to-sqlite3-database-from-cakephp

To reproduce: set $config['connect'] to an invalid value.

I have submitted a bugfix here: https://github.com/stormsaber/datasources/commit/1b7ca41472a56e7f6b8a7150a1ef8fd17227b1a1

All the best,

Daniel

AD7six commented 10 years ago

Closing as the PR #31 coverts this