partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 8c1385a7a033ef2fded7e5bc281821dd41278b57
parent 4e3923989652a3e8f74787bfc76b07ae4dea3d52
Author: Felicitus <felicitus@felicitus.org>
Date:   Fri, 10 Feb 2012 01:45:26 +0100

Refactored the error message transmitting as "message" for compatibility with the SerializableException

Diffstat:
Msrc/frontend/js/Util/ServiceCall.js | 2+-
Msrc/setup/check-php-prerequisites.php | 6+++---
Msrc/setup/check-php.php | 4++--
Msrc/setup/js/SetupTests/AbstractTest.js | 2+-
Msrc/setup/setup.php | 13++++++++-----
Msrc/setup/tests/check-database-connectivity.php | 10+++++-----
Msrc/setup/tests/check-doctrine.php | 8++++----
Msrc/setup/tests/check-permissions.php | 2+-
Msrc/setup/tests/check-php-settings.php | 12++++++------
9 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/src/frontend/js/Util/ServiceCall.js b/src/frontend/js/Util/ServiceCall.js @@ -58,7 +58,7 @@ Ext.define('PartKeepr.ServiceCall', { }; if (!this.anonymous) { - headers.session = PartKeepr.getApplication().getSession(); + headers.session = PartKeepr.getApplication().getSessionManager().getSession(); } Ext.Ajax.request({ diff --git a/src/setup/check-php-prerequisites.php b/src/setup/check-php-prerequisites.php @@ -9,18 +9,18 @@ * Each pre-flight check consists of a json array returned in the following format: * * error: Either boolean true or false - * errormessage: An error message explaining what the error was + * message: An error message explaining what the error was */ /* We need at least PHP 5.3.0, bail out if the version is too low */ if (version_compare(PHP_VERSION, '5.3.0', '<')) { - echo '{"error":true,"errormessage":"You need at least PHP 5.3.0"}'; + echo '{"error":true,"message":"You need at least PHP 5.3.0"}'; exit; } /* json_decode is the most important function, as we communicate via JSON */ if (!function_exists("json_encode")) { - echo '{"error":true,"errormessage":"Your PHP installation lacks the function json_decode, which is mandatory for PartKeepr."}'; + echo '{"error":true,"message":"Your PHP installation lacks the function json_decode, which is mandatory for PartKeepr."}'; exit; } diff --git a/src/setup/check-php.php b/src/setup/check-php.php @@ -1,2 +1,2 @@ /** <?php echo '*'.'/ {"error": false}'; exit; ?> */ -{"error":true,"errormessage":"You don't have PHP installed on your server, or the module is not activated."}- \ No newline at end of file +{"error":true,"message":"You don't have PHP installed on your server, or the module is not activated."}+ \ No newline at end of file diff --git a/src/setup/js/SetupTests/AbstractTest.js b/src/setup/js/SetupTests/AbstractTest.js @@ -75,7 +75,7 @@ Ext.define('PartKeeprSetup.AbstractTest', { this.success = true; } else { this.success = false; - this.errorMessage = obj.errormessage; + this.errorMessage = obj.message; } if (this.callback) { diff --git a/src/setup/setup.php b/src/setup/setup.php @@ -1,10 +1,9 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Setup; -declare(encoding = 'UTF-8'); - use de\RaumZeitLabor\PartKeepr\PartKeepr, - de\RaumZeitLabor\PartKeepr\Setup\Setup; + de\RaumZeitLabor\PartKeepr\Setup\Setup, + de\RaumZeitLabor\PartKeepr\Util\SerializableException; set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL); @@ -15,7 +14,7 @@ PartKeepr::initializeClassLoaders(); try { Setup::setDatabaseConfigurationFromRequest(); } catch (\Exception $e) { - echo json_encode(array("error" => true, "errormessage" => $e->getMessage())); + echo json_encode(array("error" => true, "message" => $e->getMessage())); exit; } @@ -32,7 +31,11 @@ try { } $setup->runStep($_REQUEST["step"]); echo json_encode(array("error" => false)); +} catch (SerializableException $e) { + $error = $e->serialize(); + $error["error"] = true; + echo json_encode($error); } catch (\Exception $e) { - echo json_encode(array("error" => true, "errormessage" => "An unexpected error occured during installation. The error message was:<br/><code>".$e->getMessage()."</code> and happened in <code>".$e->getFile().":".$e->getLine() )); + echo json_encode(array("error" => true, "message" => "An unexpected error occured during installation. The error message was:<br/><code>".$e->getMessage()."</code> and happened in <code>".$e->getFile().":".$e->getLine() )); exit; } diff --git a/src/setup/tests/check-database-connectivity.php b/src/setup/tests/check-database-connectivity.php @@ -22,7 +22,7 @@ $drivers = PDO::getAvailableDrivers(); $bDriverAvailable = false; if (!in_array($_REQUEST["driver"], $drivers)) { - echo json_encode(array("error" => true, "errormessage" => "The requested driver isn't installed as PHP pdo module. Please install the PDO driver for PHP.")); + echo json_encode(array("error" => true, "message" => "The requested driver isn't installed as PHP pdo module. Please install the PDO driver for PHP.")); exit; } @@ -33,7 +33,7 @@ try { $onnectionOptions = Setup::setDatabaseConfigurationFromRequest(); $connectionOptions = PartKeepr::createConnectionOptionsFromConfig(); } catch (\Exception $e) { - echo json_encode(array("error" => true, "errormessage" => $e->getMessage())); + echo json_encode(array("error" => true, "message" => $e->getMessage())); exit; } @@ -44,10 +44,10 @@ try { } catch (\PDOException $e) { $additionalMessage = getPlatformSpecificErrorMessage($_REQUEST["driver"], $e->getCode()); - echo json_encode(array("error" => true, "errormessage" => "There was an error connecting to the database:<br/><code>".$e->getMessage()."</code>".$additionalMessage)); + echo json_encode(array("error" => true, "message" => "There was an error connecting to the database:<br/><code>".$e->getMessage()."</code>".$additionalMessage)); exit; } catch (\Exception $e) { - echo json_encode(array("error" => true, "errormessage" => "An unknown error occured. The error is: <code>".$e->getMessage()."</code>")); + echo json_encode(array("error" => true, "message" => "An unknown error occured. The error is: <code>".$e->getMessage()."</code>")); exit; } @@ -60,7 +60,7 @@ switch ($_REQUEST["driver"]) { function performAdditionalMySQLTests ($connection, $dbname) { if (!SchemaSetup::mysqlHasUTF8Encoding($connection, $dbname)) { - echo json_encode(array("error" => true, "errormessage" => "Your database doesn't have the proper encoding. Please change it using the following SQL statement: <br/><br/><code>ALTER DATABASE ".$dbname." CHARACTER SET utf8;</code>")); + echo json_encode(array("error" => true, "message" => "Your database doesn't have the proper encoding. Please change it using the following SQL statement: <br/><br/><code>ALTER DATABASE ".$dbname." CHARACTER SET utf8;</code>")); exit; } diff --git a/src/setup/tests/check-doctrine.php b/src/setup/tests/check-doctrine.php @@ -12,7 +12,7 @@ $installDoctrineError .= "pear install pear.doctrine-project.org/DoctrineORM</co if (!class_exists("\\Doctrine\\Common\ClassLoader")) { $installDoctrineError .= "<small>Doctrine\\Common\\ClassLoader was not found</small>"; - echo json_encode(array("error" => true, "errormessage" => $installDoctrineError)); + echo json_encode(array("error" => true, "message" => $installDoctrineError)); exit; } @@ -40,7 +40,7 @@ $doctrineClassLoader->register(); */ if (!$ormClassLoader->canLoadClass("Doctrine\\ORM\\Version")) { $installDoctrineError .= "<small>The classloader can't load Doctrine\\ORM\\Version</small>"; - echo json_encode(array("error" => true, "errormessage" => $installDoctrineError)); + echo json_encode(array("error" => true, "message" => $installDoctrineError)); exit; } @@ -51,7 +51,7 @@ if (\Doctrine\ORM\Version::compare("2.1.0") == 1) { $versionInvalidMessage = "DoctrineORM is installed, but needs to be at Version 2.1.0 or higher. "; $versionInvalidMessage .= "Please run pear upgrade-all to bring your packages up-to-date."; - echo json_encode(array("error" => true, "errormessage" => $versionInvalidMessage)); + echo json_encode(array("error" => true, "message" => $versionInvalidMessage)); exit; } @@ -70,7 +70,7 @@ if (!$doctrineClassLoader->canLoadClass("Doctrine\\Symfony\\Component\\Yaml\\Yam $yamlErrorMessage .= "please REINSTALL the package using <code>pear uninstall doctrine/DoctrineSymfonyYaml<br/>"; $yamlErrorMessage .= "pear install doctrine/DoctrineSymfonyYaml</code>"; - echo json_encode(array("error" => true, "errormessage" => $yamlErrorMessage)); + echo json_encode(array("error" => true, "message" => $yamlErrorMessage)); exit; } diff --git a/src/setup/tests/check-permissions.php b/src/setup/tests/check-permissions.php @@ -2,7 +2,7 @@ $dataDir = dirname(dirname(dirname(__FILE__)))."/data"; if (!is_writable_recursive($dataDir)) { - echo json_encode(array("error" => true, "errormessage" => "The directory /data is not writable<br/>Please adjust the filesystem permissions so that your webserver can write into that directory.")); + echo json_encode(array("error" => true, "message" => "The directory /data is not writable<br/>Please adjust the filesystem permissions so that your webserver can write into that directory.")); exit; } diff --git a/src/setup/tests/check-php-settings.php b/src/setup/tests/check-php-settings.php @@ -8,7 +8,7 @@ if (ini_get("safe_mode")) { $errorMessage .= "kind. Please disable it by setting safe_mode=off in your php.ini file (don't forget to restart "; $errorMessage .= "your web server afterwards)"; - echo json_encode(array("error" => true, "errormessage" => $errorMessage)); + echo json_encode(array("error" => true, "message" => $errorMessage)); exit; } @@ -21,7 +21,7 @@ if (ini_get("allow_url_fopen") == false) { $errorMessage .= "Please set<br/><code>allow_url_fopen = On</code> in your php.ini file. "; $errorMessage .= "Don't forget to restart your web server afterwards."; - echo json_encode(array("error" => true, "errormessage" => $errorMessage)); + echo json_encode(array("error" => true, "message" => $errorMessage)); exit; } @@ -30,7 +30,7 @@ if (ini_get("allow_url_fopen") == false) { */ if (!function_exists("curl_init")) { $errorMessage = "You are missing the curl-library for PHP. Please install and activate it."; - echo json_encode(array("error" => true, "errormessage" => $errorMessage)); + echo json_encode(array("error" => true, "message" => $errorMessage)); exit; } @@ -39,7 +39,7 @@ if (!function_exists("curl_init")) { */ if (!class_exists("\\finfo")) { $errorMessage = "You are missing the fileinfo-library for PHP. Please install and activate it."; - echo json_encode(array("error" => true, "errormessage" => $errorMessage)); + echo json_encode(array("error" => true, "message" => $errorMessage)); exit; } @@ -48,7 +48,7 @@ if (!class_exists("\\finfo")) { */ if (!class_exists("\\Imagick")) { $errorMessage = "You are missing the Imagick library for PHP. Please install and activate it."; - echo json_encode(array("error" => true, "errormessage" => $errorMessage)); + echo json_encode(array("error" => true, "message" => $errorMessage)); exit; } @@ -59,7 +59,7 @@ if (!isTimezoneSetAndValid()) { $errorMessage = "The PHP timezone (%s) is not set or invalid. Please set the correct timezone in your"; $errorMessage .= " php.ini file (don't forget to restart the web server afterwards)"; - echo json_encode(array("error" => true, "errormessage" => sprintf($errorMessage, ini_get("date.timezone")))); + echo json_encode(array("error" => true, "message" => sprintf($errorMessage, ini_get("date.timezone")))); exit; }