display a warning when unable to connect to database
This commit is contained in:
committed by
pavel-mailpoet
parent
4a94c29b85
commit
c413acd93d
@ -13,6 +13,8 @@ require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
|||||||
|
|
||||||
class Initializer {
|
class Initializer {
|
||||||
|
|
||||||
|
const UNABLE_TO_CONNECT = '<strong>Mailpoet:</strong> Unable to connect to the database (the database is unable to open a file or folder), the connection is likely not configured correctly. Please read our <a href="http://beta.docs.mailpoet.com/article/200-solving-database-connection-issues">Knowledge Base article</a> for steps how to resolve it.';
|
||||||
|
|
||||||
protected $plugin_initialized = false;
|
protected $plugin_initialized = false;
|
||||||
|
|
||||||
function __construct($params = array(
|
function __construct($params = array(
|
||||||
@ -34,8 +36,7 @@ class Initializer {
|
|||||||
try {
|
try {
|
||||||
$this->setupDB();
|
$this->setupDB();
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
$this->handleFailedInitialization($e);
|
return WPNotice::displayWarning(self::UNABLE_TO_CONNECT);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// activation function
|
// activation function
|
||||||
@ -236,11 +237,11 @@ class Initializer {
|
|||||||
$conflict_resolver->init();
|
$conflict_resolver->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFailedInitialization($message) {
|
function handleFailedInitialization($exception) {
|
||||||
// Check if we are able to add pages at this point
|
// Check if we are able to add pages at this point
|
||||||
if(function_exists('wp_get_current_user')) {
|
if(function_exists('wp_get_current_user')) {
|
||||||
Menu::addErrorPage();
|
Menu::addErrorPage();
|
||||||
}
|
}
|
||||||
return WPNotice::displayError($message);
|
return WPNotice::displayError($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user