summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-02-03 02:35:13 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2013-02-03 02:35:13 -0500
commit675fd21cf145ff882463d604fe9e4bf9defa256e (patch)
tree394a8fbc073b1e7bda9de012e88b627247d20e58
parentab1856901367eab3ee390047f7829bdabfd2410d (diff)
downloadampache-675fd21cf145ff882463d604fe9e4bf9defa256e.tar.gz
ampache-675fd21cf145ff882463d604fe9e4bf9defa256e.tar.bz2
ampache-675fd21cf145ff882463d604fe9e4bf9defa256e.zip
Add a check that makes sure PDO is available
Calling an unavailable class is a fatal error, so people without PDO were left with a fairly useless blank screen and no indicator of what was wrong. Let's be a bit more user-friendly.
-rw-r--r--lib/debug.lib.php13
-rw-r--r--lib/init.php2
-rw-r--r--templates/show_test.inc.php14
3 files changed, 26 insertions, 3 deletions
diff --git a/lib/debug.lib.php b/lib/debug.lib.php
index f1c5dbcc..f96c9ffa 100644
--- a/lib/debug.lib.php
+++ b/lib/debug.lib.php
@@ -74,6 +74,19 @@ function check_php_pcre() {
} // check_php_pcre
/**
+ * check_pdo
+ *
+ * Checks to make sure that PDO is available.
+ */
+function check_pdo() {
+ if (class_exists('PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
+ return true;
+ }
+
+ return false;
+}
+
+/**
* check_config_values
* checks to make sure that they have at least set the needed variables
*/
diff --git a/lib/init.php b/lib/init.php
index 9955c088..8b8248f0 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -53,7 +53,7 @@ else {
// Verify that a few important but commonly disabled PHP functions exist and
// that we're on a usable version
-if (!function_exists('hash') || !function_exists('inet_pton') || (floatval(phpversion()) < 5.3)) {
+if (!function_exists('hash') || !function_exists('inet_pton') || (floatval(phpversion()) < 5.3) || !class_exists('PDO')) {
$link = $path . '/test.php';
}
diff --git a/templates/show_test.inc.php b/templates/show_test.inc.php
index fcd6c703..6a2b2b2b 100644
--- a/templates/show_test.inc.php
+++ b/templates/show_test.inc.php
@@ -62,6 +62,16 @@
</td>
</tr>
<tr>
+ <td valign="top"><?php echo T_('PHP PDO'); ?></td>
+ <td valign="top">[
+ <?php echo debug_result('', check_pdo()); ?>
+ ]
+ </td>
+ <td>
+ <?php echo T_('This tests whether the PDO extension and the MySQL driver for PDO are installed. These are required by Ampache.'); ?>
+ </td>
+</tr>
+<tr>
<td valign="top"><?php echo T_('PHP session extension'); ?></td>
<td valign="top">[
<?php
@@ -170,7 +180,7 @@
<td valign="top"><?php echo T_("Database connection"); ?></td>
<td valign="top">[
<?php
- if (!Dba::check_database()) {
+ if (!check_pdo() || !Dba::check_database()) {
echo debug_result('',false);
}
else {
@@ -187,7 +197,7 @@
<td valign="top"><?php echo T_('Database tables'); ?></td>
<td valign="top">[
<?php
- $db_inserted = Dba::check_database_inserted();
+ $db_inserted = check_pdo() ? Dba::check_database_inserted() : false;
if (!$db_inserted) {
echo debug_result('',false);
}