From c413acd93da42f964c52df56384dd5793937b015 Mon Sep 17 00:00:00 2001 From: Amine Ben hammou Date: Tue, 18 Jul 2017 12:54:12 +0000 Subject: [PATCH] display a warning when unable to connect to database --- lib/Config/Initializer.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Config/Initializer.php b/lib/Config/Initializer.php index a514fc9cbc..a0f48b510f 100644 --- a/lib/Config/Initializer.php +++ b/lib/Config/Initializer.php @@ -13,6 +13,8 @@ require_once(ABSPATH . 'wp-admin/includes/plugin.php'); class Initializer { + const UNABLE_TO_CONNECT = 'Mailpoet: 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 Knowledge Base article for steps how to resolve it.'; + protected $plugin_initialized = false; function __construct($params = array( @@ -34,8 +36,7 @@ class Initializer { try { $this->setupDB(); } catch(\Exception $e) { - $this->handleFailedInitialization($e); - return; + return WPNotice::displayWarning(self::UNABLE_TO_CONNECT); } // activation function @@ -236,11 +237,11 @@ class Initializer { $conflict_resolver->init(); } - function handleFailedInitialization($message) { + function handleFailedInitialization($exception) { // Check if we are able to add pages at this point if(function_exists('wp_get_current_user')) { Menu::addErrorPage(); } - return WPNotice::displayError($message); + return WPNotice::displayError($exception); } }