Author: ralfbecker
New Revision: 55177
URL: http://svn.stylite.de/viewvc/egroupware?rev=55177&view=rev
Log:
move exceptions to new api structure, thought to catch an exception by its deprecated name, new exceptions have to extend deprecated ones
Added:
trunk/egroupware/api/src/Db/Exception/
trunk/egroupware/api/src/Db/Exception.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Db/Exception/Connection.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Db/Exception/InvalidSql.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Db/Exception/NotUnique.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Db/Exception/Setup.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Db/Exception/Support.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/
trunk/egroupware/api/src/Exception.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/AssertionFailed.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/NoPermission/
trunk/egroupware/api/src/Exception/NoPermission.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/NoPermission/Admin.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/NoPermission/App.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/NoPermission/Record.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/NotFound.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/Redirect.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/WrongParameter.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/egroupware/api/src/Exception/WrongUserInput.php
- copied, changed from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php
Modified:
trunk/egroupware/api/src/Cache.php
trunk/egroupware/api/src/Db.php
trunk/egroupware/api/src/Db/Backup.php
trunk/egroupware/api/src/Db/Deprecated.php
trunk/egroupware/api/src/Db/Schema.php
trunk/egroupware/api/src/Vfs.php
trunk/egroupware/api/src/Vfs/Sqlfs/StreamWrapper.php
trunk/egroupware/api/src/Vfs/Sqlfs/Utils.php
trunk/egroupware/api/src/Vfs/StreamWrapper.php
trunk/phpgwapi/inc/class.egw.inc.php
trunk/phpgwapi/inc/class.egw_exception.inc.php
trunk/phpgwapi/inc/common_functions.inc.php
trunk/setup/inc/class.setup_detection.inc.php
— trunk/egroupware/api/src/Cache.php (original)
+++ trunk/egroupware/api/src/Cache.php Sun Feb 28 14:43:06 2016
@@ -13,9 +13,8 @@
namespace EGroupware\Api;
-use egw_exception_db;
-use egw_exception_wrong_parameter;
use egw_session;
+use config;
/**
- Class to manage caching in eGroupware.
@@ -119,7 +118,7 @@
{
case self::SESSION:
case self::REQUEST:
@@ -135,7 +134,7 @@
}
return $provider->add(self::keys($level,$app,$location),$data,$expiration);
}
-
throw new Api\Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
}
/**
@@ -171,7 +170,7 @@
}
return $provider->set(self::keys($level,$app,$location),$data,$expiration);
}
-
throw new Api\Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
}
/**
@@ -210,7 +209,7 @@
{
if (!is_null($callback))
{
@@ -247,7 +246,7 @@
}
return $data;
}
-
throw new Api\Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
}
/**
@@ -275,7 +274,7 @@
}
return $provider->delete(self::keys($level,$app,$location));
}
-
throw new Api\Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
}
/**
@@ -591,7 +590,7 @@
error_log(METHOD."(’$name’, $throw) config value NOT found!");//.function_backtrace());
}
}
@@ -730,7 +729,7 @@
*/
function __construct()
{
— trunk/egroupware/api/src/Db.php (original)
+++ trunk/egroupware/api/src/Db.php Sun Feb 28 14:43:06 2016
@@ -12,10 +12,6 @@
*/
namespace EGroupware\Api;
-use egw_exception_db_connection;
-use egw_exception_db_invalid_sql;
-use egw_exception_wrong_parameter;
if(empty($GLOBALS[‘egw_info’][‘server’][‘db_type’]))
{
@@ -170,7 +166,7 @@
/**
* Callback to check if selected node is healty / should be used
*
-
-
@var callback throwing egw_exception_db_connection, if connected node should NOT be used
-
-
@var callback throwing Api\Db\Exception\Connection, if connected node should NOT be used
*/
static $health_check;
@@ -299,7 +295,7 @@
* @param string $User name of database user (optional)
* @param string $Password password for database user (optional)
* @param string $Type type of database (optional)
-
-
@throws egw_exception_db_connection
-
-
@throws Api\Db\Exception\Connection
-
@return ADOConnection
*/
function connect($Database = NULL, $Host = NULL, $Port = NULL, $User = NULL, $Password = NULL,$Type = NULL)
@@ -350,7 +346,7 @@
//error_log(METHOD."() host=$host, new_connection=$new_connection, this->Type=$this->Type, this->Host=$this->Host, wsrep_local_state=".array2string($state));
return $this->Link_ID;
}
@@ -359,7 +355,7 @@
}
if (!isset($e))
{
-
-
@throws egw_exception_db_connection if node should NOT be used
-
-
@throws Api\Db\Exception\Connection if node should NOT be used
*/
static function galera_cluster_health(Db $db)
{
@@ -389,7 +385,7 @@
$state[‘wsrep_local_state_comment’] == ‘Donor/Desynced’ &&
$state[‘wsrep_cluster_size’] == 2) return;
@@ -426,7 +422,7 @@
*
* @param string $Host host to connect to
* @return ADOConnection
-
-
@throws egw_exception_db_connection
-
-
@throws Api\Db\Exception\Connection
*/
protected function _connect($Host)
{
@@ -503,7 +499,7 @@
{
if (!check_load_extension($php_extension))
{
@@ -516,7 +512,7 @@
$this->Link_ID = ADONewConnection($Type);
if (!$this->Link_ID)
{
@@ -532,7 +528,7 @@
if (!$Ok)
{
$Host = preg_replace(’/password=[^ ]+/’,‘password=$Password’,$Host); // eg. postgres dsn contains password
-
throw new egw_exception_db_connection("ADOdb::$connect($Host, $User, \$Password, $Database) failed.");
-
throw new Api\Db\Exception\Connection("ADOdb::$connect($Host, $User, \$Password, $Database) failed.");
}
if ($this->Debug)
{
@@ -563,7 +559,7 @@
if (!$this->Link_ID->isConnected() && !$this->Link_ID->Connect())
{
$Host = preg_replace(’/password=[^ ]+/’,‘password=$Password’,$Host); // eg. postgres dsn contains password
-
throw new egw_exception_db_connection("ADOdb::$connect($Host, $User, \$Password, $Database) reconnect failed.");
-
throw new Api\Db\Exception\Connection("ADOdb::$connect($Host, $User, \$Password, $Database) reconnect failed.");
}
// fix due to caching and reusing of connection not correctly set $this->Type == 'mysql'
if ($this->Type == 'mysqli')
@@ -724,7 +720,7 @@
* @param int $fetchmode =self::FETCH_BOTH self::FETCH_BOTH (default), self::FETCH_ASSOC or self::FETCH_NUM
* @param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!)
* @return ADORecordSet or false, if the query fails
-
-
@throws egw_exception_db_invalid_sql with $this->Link_ID->ErrorNo() as code
-
-
@throws Api\Db\Exception\InvalidSql with $this->Link_ID->ErrorNo() as code
*/
function query($Query_String, $line = ‘’, $file = ‘’, $offset=0, $num_rows=-1, $inputarr=false, $fetchmode=self::FETCH_BOTH, $reconnect=true)
{
@@ -781,7 +777,7 @@
$this->disconnect();
return $this->query($Query_String, $line, $file, $offset, $num_rows, $inputarr, $fetchmode, false);
}
-
throw new Api\Db\Exception\InvalidSql("Invalid SQL: ".(is_array($Query_String)?$Query_String[0]:$Query_String).
"\n$this->Error ($this->Errno)".
($inputarr ? "\nParameters: '".implode("','",$inputarr)."'":''), $this->Errno);
}
@@ -1473,7 +1469,7 @@
if (strpos($key, ‘.’) !== false) list(, $col) = explode(’.’, $key);
if (!isset($column_definitions[$col]))
{
-
throw new egw_exception_db_invalid_sql("db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre><b>nothing known about column '$key'!</b>");
-
throw new Api\Db\Exception\InvalidSql("db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre><b>nothing known about column '$key'!</b>");
}
}
$column_type = is_array($column_definitions) ? @$column_definitions[$col]['type'] : False;
@@ -1566,7 +1562,7 @@
if ($this === $GLOBALS[‘egw’]->db && $app != self::API_APPNAME)
{
// prevent that anyone switches the global db object to an other app
@@ -1869,7 +1865,7 @@
{
$ret = $this->Link_ID->UpdateBlob($table,$col,$val,$where_str,$table_def[‘fd’][$col][‘type’] == ‘blob’ ? ‘BLOB’ : ‘CLOB’);
if ($this->Debug) echo “
adodb::UpdateBlob(’$table’,’$col’,’$val’,’$where_str’) = ‘$ret’
\n”;
-
if (!$ret) throw new egw_exception_db_invalid_sql("Error in UpdateBlob($table,$col,\$val,$where_str)",$line,$file);
-
if (!$ret) throw new Api\Db\Exception\InvalidSql("Error in UpdateBlob($table,$col,\$val,$where_str)",$line,$file);
}
}
return $ret;
— trunk/egroupware/api/src/Db/Backup.php (original)
+++ trunk/egroupware/api/src/Db/Backup.php Sun Feb 28 14:43:06 2016
@@ -15,7 +15,6 @@
use EGroupware\Api;
-use egw_exception_db_invalid_sql;
use config;
use translation;
use html;
@@ -667,7 +666,7 @@
try {
$this->db->insert($table,$data,False,LINE,FILE,false,false,$this->schemas[$table]);
}
@@ -715,7 +714,7 @@
try {
$this->db->insert($table, $rows, False, LINE, FILE, false, false, $schema);
}
@@ -723,7 +722,7 @@
try {
$this->db->insert($table, $data, False, LINE, FILE, false, false, $schema);
}
— trunk/egroupware/api/src/Db/Deprecated.php (original)
+++ trunk/egroupware/api/src/Db/Deprecated.php Sun Feb 28 14:43:06 2016
@@ -14,7 +14,6 @@
namespace EGroupware\Api\Db;
use EGroupware\Api;
-use egw_exception_db;
/**
- Deprecated functionality we still need to support

@@ -53,7 +52,7 @@
-
@param int $fetchmode =self::FETCH_BOTH self::FETCH_BOTH (default), self::FETCH_ASSOC or self::FETCH_NUM
-
@param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!)
-
@return ADORecordSet or false, if the query fails
-
-
@throws egw_exception_db_invalid_sql with $this->Link_ID->ErrorNo() as code
-
-
@throws EGroupware\Api\Db\Exception\InvalidSql with $this->Link_ID->ErrorNo() as code
*/
function query($Query_String, $line = ‘’, $file = ‘’, $offset=0, $num_rows=-1, $inputarr=false, $fetchmode=self::FETCH_BOTH, $reconnect=true)
{
@@ -120,7 +119,7 @@
{
if (!$this->Query_ID)
{
@@ -175,7 +174,7 @@
{
if (!$this->Query_ID || !$this->Query_ID->Move($this->Row = $pos))
{
— trunk/phpgwapi/inc/class.egw_exception.inc.php (original)
+++ trunk/egroupware/api/src/Db/Exception.php Sun Feb 28 14:43:06 2016
@@ -1,150 +1,25 @@
<?php
/**
- * eGroupWare API - Exceptions
- *
- * This file defines as set of Exceptions used in eGroupWare.
- *
- * Applications having the need for further exceptions should extends the from one defined in this file.
+ * EGroupware API - Db Exceptions
*
* @link http://www.egroupware.org
* @author Ralf Becker
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
- * @subpackage accounts
+ * @subpackage db
* @access public
* @version $Id$
*/
-/**
- * eGroupWare API - Exceptions
- *
- * All eGroupWare exceptions should extended this class, so we are able to eg. add some logging later.
- *
- * The messages for most exceptions should be translated and ready to be displayed to the user.
- * Only exception to this are exceptions like egw_exception_assertion_fails, egw_exception_wrong_parameter
- * or egw_exception_db, which are suppost to happen only during program development.
- */
-class egw_exception extends Exception
-{
- // nothing fancy yet
- function __construct($msg=null,$code=100,Exception $previous=null)
- {
- return parent::__construct($msg, $code, $previous);
- }
-}
-
-/**
- * Base class for all exceptions about missing permissions
- *
- */
-class egw_exception_no_permission extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Permission denied!"
- * @param int $code =100 numerical code, default 100
- */
- function __construct($msg=null,$code=100)
- {
- if (is_null($msg)) $msg = lang('Permisson denied!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks the right to run an application
- *
- */
-class egw_exception_no_permission_app extends egw_exception_no_permission
-{
- function __construct($msg=null,$code=101)
- {
- if (isset($GLOBALS['egw_info']['apps'][$msg]))
- {
- if ($msg == 'admin')
- {
- $msg = lang('You need to be an eGroupWare administrator to access this functionality!');
- }
- else
- {
- $currentapp = $GLOBALS['egw_info']['flags']['currentapp'];
- $app = isset($GLOBALS['egw_info']['apps'][$currentapp]['title']) ?
- $GLOBALS['egw_info']['apps'][$currentapp]['title'] : $msg;
-
- $msg = lang('You\'ve tried to open the eGroupWare application: %1, but you have no permission to access this application.',
- '"'.$app.'"');
- }
- }
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User is no eGroupWare admin (no right to run the admin application)
- *
- */
-class egw_exception_no_permission_admin extends egw_exception_no_permission_app
-{
- function __construct($msg=null,$code=102)
- {
- if (is_null($msg)) $msg = 'admin';
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks a record level permission, eg. he's not the owner and has no grant from the owner
- *
- */
-class egw_exception_no_permission_record extends egw_exception_no_permission { }
-
-/**
- * A record or application entry was not found for the given id
- *
- */
-class egw_exception_not_found extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Entry not found!"
- * @param int $code =99 numerical code, default 2
- */
- function __construct($msg=null,$code=2)
- {
- if (is_null($msg)) $msg = lang('Entry not found!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * An necessary assumption the developer made failed, regular execution can not continue
- *
- * As you get this only by an error in the code or during development, the message does not need to be translated
- */
-class egw_exception_assertion_failed extends egw_exception { }
-
-/**
- * A method or function was called with a wrong or missing parameter
- *
- * As you get this only by an error in the code or during development, the message does not need to be translated
- */
-class egw_exception_wrong_parameter extends egw_exception_assertion_failed { }
-
-/**
- * Wrong or missing required user input: message should be translated so it can be shown directly to the user
- *
- */
-class egw_exception_wrong_userinput extends egw_exception_assertion_failed { }
+namespace EGroupware\Api\Db;
/**
* Exception thrown by the egw_db class for everything not covered by extended classed below
+ *
+ * New Db\Exception has to extend deprecated egw_exception_db to allow legacy code
+ * to catch exceptions thrown by Api\Db class!
*/
-class egw_exception_db extends egw_exception
+class Exception extends \egw_exception_db
{
/**
* Constructor
@@ -159,55 +34,3 @@
parent::__construct($msg,$code);
}
}
-
-/**
- * Storing the row violates a unique key constrain
- */
-class egw_exception_db_not_unique extends egw_exception_db { }
-
-/**
- * Can not connect to database: eg. database down, wrong host, name or credentials
- */
-class egw_exception_db_connection extends egw_exception_db { }
-
-/**
- * PHP lackst support for configured database type
- */
-class egw_exception_db_support extends egw_exception_db { }
-
-/**
- * Classic invalid SQL error
- */
-class egw_exception_db_invalid_sql extends egw_exception_db { }
-
-/**
- * EGroupware not (fully) installed, visit setup
- */
-class egw_exception_db_setup extends egw_exception_db { }
-
-/**
- * Allow callbacks to request a redirect
- *
- * Can be caught be applications and is otherwise handled by global exception handler.
- */
-class egw_exception_redirect extends egw_exception
-{
- public $url;
- public $app;
-
- /**
- * Constructor
- *
- * @param string $url
- * @param string $app
- * @param string $msg
- * @param int $code
- */
- function __construct($url,$app=null,$msg=null,$code=301)
- {
- $this->url = $url;
- $this->app = $app;
-
- parent::__construct($msg, $code);
- }
-}
Copied: trunk/egroupware/api/src/Db/Exception/Connection.php (from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php)
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Db/Exception/Connection.php?p2=trunk/egroupware/api/src/Db/Exception/Connection.php&p1=trunk/phpgwapi/inc/class.egw_exception.inc.php&r1=55168&r2=55177&rev=55177&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.egw_exception.inc.php (original)
+++ trunk/egroupware/api/src/Db/Exception/Connection.php Sun Feb 28 14:43:06 2016
@@ -1,213 +1,21 @@
<?php
/**
- * eGroupWare API - Exceptions
- *
- * This file defines as set of Exceptions used in eGroupWare.
- *
- * Applications having the need for further exceptions should extends the from one defined in this file.
+ * EGroupware API - Db Exceptions
*
* @link http://www.egroupware.org
* @author Ralf Becker
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
- * @subpackage accounts
+ * @subpackage db
* @access public
* @version $Id$
*/
-/**
- * eGroupWare API - Exceptions
- *
- * All eGroupWare exceptions should extended this class, so we are able to eg. add some logging later.
- *
- * The messages for most exceptions should be translated and ready to be displayed to the user.
- * Only exception to this are exceptions like egw_exception_assertion_fails, egw_exception_wrong_parameter
- * or egw_exception_db, which are suppost to happen only during program development.
- */
-class egw_exception extends Exception
-{
- // nothing fancy yet
- function __construct($msg=null,$code=100,Exception $previous=null)
- {
- return parent::__construct($msg, $code, $previous);
- }
-}
+namespace EGroupware\Api\Db\Exception;
-/**
- * Base class for all exceptions about missing permissions
- *
- */
-class egw_exception_no_permission extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Permission denied!"
- * @param int $code =100 numerical code, default 100
- */
- function __construct($msg=null,$code=100)
- {
- if (is_null($msg)) $msg = lang('Permisson denied!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks the right to run an application
- *
- */
-class egw_exception_no_permission_app extends egw_exception_no_permission
-{
- function __construct($msg=null,$code=101)
- {
- if (isset($GLOBALS['egw_info']['apps'][$msg]))
- {
- if ($msg == 'admin')
- {
- $msg = lang('You need to be an eGroupWare administrator to access this functionality!');
- }
- else
- {
- $currentapp = $GLOBALS['egw_info']['flags']['currentapp'];
- $app = isset($GLOBALS['egw_info']['apps'][$currentapp]['title']) ?
- $GLOBALS['egw_info']['apps'][$currentapp]['title'] : $msg;
-
- $msg = lang('You\'ve tried to open the eGroupWare application: %1, but you have no permission to access this application.',
- '"'.$app.'"');
- }
- }
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User is no eGroupWare admin (no right to run the admin application)
- *
- */
-class egw_exception_no_permission_admin extends egw_exception_no_permission_app
-{
- function __construct($msg=null,$code=102)
- {
- if (is_null($msg)) $msg = 'admin';
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks a record level permission, eg. he's not the owner and has no grant from the owner
- *
- */
-class egw_exception_no_permission_record extends egw_exception_no_permission { }
-
-/**
- * A record or application entry was not found for the given id
- *
- */
-class egw_exception_not_found extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Entry not found!"
- * @param int $code =99 numerical code, default 2
- */
- function __construct($msg=null,$code=2)
- {
- if (is_null($msg)) $msg = lang('Entry not found!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * An necessary assumption the developer made failed, regular execution can not continue
- *
- * As you get this only by an error in the code or during development, the message does not need to be translated
- */
-class egw_exception_assertion_failed extends egw_exception { }
-
-/**
- * A method or function was called with a wrong or missing parameter
- *
- * As you get this only by an error in the code or during development, the message does not need to be translated
- */
-class egw_exception_wrong_parameter extends egw_exception_assertion_failed { }
-
-/**
- * Wrong or missing required user input: message should be translated so it can be shown directly to the user
- *
- */
-class egw_exception_wrong_userinput extends egw_exception_assertion_failed { }
-
-/**
- * Exception thrown by the egw_db class for everything not covered by extended classed below
- */
-class egw_exception_db extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Database error!"
- * @param int $code =100
- */
- function __construct($msg=null,$code=100)
- {
- if (is_null($msg)) $msg = lang('Database error!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * Storing the row violates a unique key constrain
- */
-class egw_exception_db_not_unique extends egw_exception_db { }
+use EGroupware\Api\Db;
/**
* Can not connect to database: eg. database down, wrong host, name or credentials
*/
-class egw_exception_db_connection extends egw_exception_db { }
-
-/**
- * PHP lackst support for configured database type
- */
-class egw_exception_db_support extends egw_exception_db { }
-
-/**
- * Classic invalid SQL error
- */
-class egw_exception_db_invalid_sql extends egw_exception_db { }
-
-/**
- * EGroupware not (fully) installed, visit setup
- */
-class egw_exception_db_setup extends egw_exception_db { }
-
-/**
- * Allow callbacks to request a redirect
- *
- * Can be caught be applications and is otherwise handled by global exception handler.
- */
-class egw_exception_redirect extends egw_exception
-{
- public $url;
- public $app;
-
- /**
- * Constructor
- *
- * @param string $url
- * @param string $app
- * @param string $msg
- * @param int $code
- */
- function __construct($url,$app=null,$msg=null,$code=301)
- {
- $this->url = $url;
- $this->app = $app;
-
- parent::__construct($msg, $code);
- }
-}
+class Connection extends Db\Exception { }
Copied: trunk/egroupware/api/src/Db/Exception/InvalidSql.php (from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php)
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Db/Exception/InvalidSql.php?p2=trunk/egroupware/api/src/Db/Exception/InvalidSql.php&p1=trunk/phpgwapi/inc/class.egw_exception.inc.php&r1=55168&r2=55177&rev=55177&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.egw_exception.inc.php (original)
+++ trunk/egroupware/api/src/Db/Exception/InvalidSql.php Sun Feb 28 14:43:06 2016
@@ -1,213 +1,22 @@
<?php
/**
- * eGroupWare API - Exceptions
- *
- * This file defines as set of Exceptions used in eGroupWare.
- *
- * Applications having the need for further exceptions should extends the from one defined in this file.
+ * EGroupware API - Db Exceptions
*
* @link http://www.egroupware.org
* @author Ralf Becker
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
- * @subpackage accounts
+ * @subpackage db
* @access public
* @version $Id$
*/
-/**
- * eGroupWare API - Exceptions
- *
- * All eGroupWare exceptions should extended this class, so we are able to eg. add some logging later.
- *
- * The messages for most exceptions should be translated and ready to be displayed to the user.
- * Only exception to this are exceptions like egw_exception_assertion_fails, egw_exception_wrong_parameter
- * or egw_exception_db, which are suppost to happen only during program development.
- */
-class egw_exception extends Exception
-{
- // nothing fancy yet
- function __construct($msg=null,$code=100,Exception $previous=null)
- {
- return parent::__construct($msg, $code, $previous);
- }
-}
-
-/**
- * Base class for all exceptions about missing permissions
- *
- */
-class egw_exception_no_permission extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Permission denied!"
- * @param int $code =100 numerical code, default 100
- */
- function __construct($msg=null,$code=100)
- {
- if (is_null($msg)) $msg = lang('Permisson denied!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks the right to run an application
- *
- */
-class egw_exception_no_permission_app extends egw_exception_no_permission
-{
- function __construct($msg=null,$code=101)
- {
- if (isset($GLOBALS['egw_info']['apps'][$msg]))
- {
- if ($msg == 'admin')
- {
- $msg = lang('You need to be an eGroupWare administrator to access this functionality!');
- }
- else
- {
- $currentapp = $GLOBALS['egw_info']['flags']['currentapp'];
- $app = isset($GLOBALS['egw_info']['apps'][$currentapp]['title']) ?
- $GLOBALS['egw_info']['apps'][$currentapp]['title'] : $msg;
-
- $msg = lang('You\'ve tried to open the eGroupWare application: %1, but you have no permission to access this application.',
- '"'.$app.'"');
- }
- }
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User is no eGroupWare admin (no right to run the admin application)
- *
- */
-class egw_exception_no_permission_admin extends egw_exception_no_permission_app
-{
- function __construct($msg=null,$code=102)
- {
- if (is_null($msg)) $msg = 'admin';
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks a record level permission, eg. he's not the owner and has no grant from the owner
- *
- */
-class egw_exception_no_permission_record extends egw_exception_no_permission { }
-
-/**
- * A record or application entry was not found for the given id
- *
- */
-class egw_exception_not_found extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Entry not found!"
- * @param int $code =99 numerical code, default 2
- */
- function __construct($msg=null,$code=2)
- {
- if (is_null($msg)) $msg = lang('Entry not found!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * An necessary assumption the developer made failed, regular execution can not continue
- *
- * As you get this only by an error in the code or during development, the message does not need to be translated
- */
-class egw_exception_assertion_failed extends egw_exception { }
-
-/**
- * A method or function was called with a wrong or missing parameter
- *
- * As you get this only by an error in the code or during development, the message does not need to be translated
- */
-class egw_exception_wrong_parameter extends egw_exception_assertion_failed { }
-
-/**
- * Wrong or missing required user input: message should be translated so it can be shown directly to the user
- *
- */
-class egw_exception_wrong_userinput extends egw_exception_assertion_failed { }
-
-/**
- * Exception thrown by the egw_db class for everything not covered by extended classed below
- */
-class egw_exception_db extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Database error!"
- * @param int $code =100
- */
- function __construct($msg=null,$code=100)
- {
- if (is_null($msg)) $msg = lang('Database error!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * Storing the row violates a unique key constrain
- */
-class egw_exception_db_not_unique extends egw_exception_db { }
-
-/**
- * Can not connect to database: eg. database down, wrong host, name or credentials
- */
-class egw_exception_db_connection extends egw_exception_db { }
-
-/**
- * PHP lackst support for configured database type
- */
-class egw_exception_db_support extends egw_exception_db { }
+namespace EGroupware\Api\Db\Exception;
/**
* Classic invalid SQL error
+ *
+ * New InvalidSql exception has to extend deprecated egw_exception_db_invalid_sql
+ * to allow legacy code to catch exceptions thrown by Api\Db!
*/
-class egw_exception_db_invalid_sql extends egw_exception_db { }
-
-/**
- * EGroupware not (fully) installed, visit setup
- */
-class egw_exception_db_setup extends egw_exception_db { }
-
-/**
- * Allow callbacks to request a redirect
- *
- * Can be caught be applications and is otherwise handled by global exception handler.
- */
-class egw_exception_redirect extends egw_exception
-{
- public $url;
- public $app;
-
- /**
- * Constructor
- *
- * @param string $url
- * @param string $app
- * @param string $msg
- * @param int $code
- */
- function __construct($url,$app=null,$msg=null,$code=301)
- {
- $this->url = $url;
- $this->app = $app;
-
- parent::__construct($msg, $code);
- }
-}
+class InvalidSql extends \egw_exception_db_invalid_sql {}
Copied: trunk/egroupware/api/src/Db/Exception/NotUnique.php (from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php)
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Db/Exception/NotUnique.php?p2=trunk/egroupware/api/src/Db/Exception/NotUnique.php&p1=trunk/phpgwapi/inc/class.egw_exception.inc.php&r1=55168&r2=55177&rev=55177&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.egw_exception.inc.php (original)
+++ trunk/egroupware/api/src/Db/Exception/NotUnique.php Sun Feb 28 14:43:06 2016
@@ -1,213 +1,21 @@
<?php
/**
- * eGroupWare API - Exceptions
- *
- * This file defines as set of Exceptions used in eGroupWare.
- *
- * Applications having the need for further exceptions should extends the from one defined in this file.
+ * EGroupware API - Db Exceptions
*
* @link http://www.egroupware.org
* @author Ralf Becker
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
- * @subpackage accounts
+ * @subpackage db
* @access public
* @version $Id$
*/
-/**
- * eGroupWare API - Exceptions
- *
- * All eGroupWare exceptions should extended this class, so we are able to eg. add some logging later.
- *
- * The messages for most exceptions should be translated and ready to be displayed to the user.
- * Only exception to this are exceptions like egw_exception_assertion_fails, egw_exception_wrong_parameter
- * or egw_exception_db, which are suppost to happen only during program development.
- */
-class egw_exception extends Exception
-{
- // nothing fancy yet
- function __construct($msg=null,$code=100,Exception $previous=null)
- {
- return parent::__construct($msg, $code, $previous);
- }
-}
+namespace EGroupware\Api\Db\Exception;
-/**
- * Base class for all exceptions about missing permissions
- *
- */
-class egw_exception_no_permission extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Permission denied!"
- * @param int $code =100 numerical code, default 100
- */
- function __construct($msg=null,$code=100)
- {
- if (is_null($msg)) $msg = lang('Permisson denied!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks the right to run an application
- *
- */
-class egw_exception_no_permission_app extends egw_exception_no_permission
-{
- function __construct($msg=null,$code=101)
- {
- if (isset($GLOBALS['egw_info']['apps'][$msg]))
- {
- if ($msg == 'admin')
- {
- $msg = lang('You need to be an eGroupWare administrator to access this functionality!');
- }
- else
- {
- $currentapp = $GLOBALS['egw_info']['flags']['currentapp'];
- $app = isset($GLOBALS['egw_info']['apps'][$currentapp]['title']) ?
- $GLOBALS['egw_info']['apps'][$currentapp]['title'] : $msg;
-
- $msg = lang('You\'ve tried to open the eGroupWare application: %1, but you have no permission to access this application.',
- '"'.$app.'"');
- }
- }
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User is no eGroupWare admin (no right to run the admin application)
- *
- */
-class egw_exception_no_permission_admin extends egw_exception_no_permission_app
-{
- function __construct($msg=null,$code=102)
- {
- if (is_null($msg)) $msg = 'admin';
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks a record level permission, eg. he's not the owner and has no grant from the owner
- *
- */
-class egw_exception_no_permission_record extends egw_exception_no_permission { }
-
-/**
- * A record or application entry was not found for the given id
- *
- */
-class egw_exception_not_found extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Entry not found!"
- * @param int $code =99 numerical code, default 2
- */
- function __construct($msg=null,$code=2)
- {
- if (is_null($msg)) $msg = lang('Entry not found!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * An necessary assumption the developer made failed, regular execution can not continue
- *
- * As you get this only by an error in the code or during development, the message does not need to be translated
- */
-class egw_exception_assertion_failed extends egw_exception { }
-
-/**
- * A method or function was called with a wrong or missing parameter
- *
- * As you get this only by an error in the code or during development, the message does not need to be translated
- */
-class egw_exception_wrong_parameter extends egw_exception_assertion_failed { }
-
-/**
- * Wrong or missing required user input: message should be translated so it can be shown directly to the user
- *
- */
-class egw_exception_wrong_userinput extends egw_exception_assertion_failed { }
-
-/**
- * Exception thrown by the egw_db class for everything not covered by extended classed below
- */
-class egw_exception_db extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Database error!"
- * @param int $code =100
- */
- function __construct($msg=null,$code=100)
- {
- if (is_null($msg)) $msg = lang('Database error!');
-
- parent::__construct($msg,$code);
- }
-}
+use EGroupware\Api\Db;
/**
* Storing the row violates a unique key constrain
*/
-class egw_exception_db_not_unique extends egw_exception_db { }
-
-/**
- * Can not connect to database: eg. database down, wrong host, name or credentials
- */
-class egw_exception_db_connection extends egw_exception_db { }
-
-/**
- * PHP lackst support for configured database type
- */
-class egw_exception_db_support extends egw_exception_db { }
-
-/**
- * Classic invalid SQL error
- */
-class egw_exception_db_invalid_sql extends egw_exception_db { }
-
-/**
- * EGroupware not (fully) installed, visit setup
- */
-class egw_exception_db_setup extends egw_exception_db { }
-
-/**
- * Allow callbacks to request a redirect
- *
- * Can be caught be applications and is otherwise handled by global exception handler.
- */
-class egw_exception_redirect extends egw_exception
-{
- public $url;
- public $app;
-
- /**
- * Constructor
- *
- * @param string $url
- * @param string $app
- * @param string $msg
- * @param int $code
- */
- function __construct($url,$app=null,$msg=null,$code=301)
- {
- $this->url = $url;
- $this->app = $app;
-
- parent::__construct($msg, $code);
- }
-}
+class NotUnique extends Db\Exception { }
Copied: trunk/egroupware/api/src/Db/Exception/Setup.php (from r55168, trunk/phpgwapi/inc/class.egw_exception.inc.php)
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Db/Exception/Setup.php?p2=trunk/egroupware/api/src/Db/Exception/Setup.php&p1=trunk/phpgwapi/inc/class.egw_exception.inc.php&r1=55168&r2=55177&rev=55177&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.egw_exception.inc.php (original)
+++ trunk/egroupware/api/src/Db/Exception/Setup.php Sun Feb 28 14:43:06 2016
@@ -1,213 +1,21 @@
<?php
/**
- * eGroupWare API - Exceptions
- *
- * This file defines as set of Exceptions used in eGroupWare.
- *
- * Applications having the need for further exceptions should extends the from one defined in this file.
+ * EGroupware API - Db Exceptions
*
* @link http://www.egroupware.org
* @author Ralf Becker
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
- * @subpackage accounts
+ * @subpackage db
* @access public
* @version $Id$
*/
-/**
- * eGroupWare API - Exceptions
- *
- * All eGroupWare exceptions should extended this class, so we are able to eg. add some logging later.
- *
- * The messages for most exceptions should be translated and ready to be displayed to the user.
- * Only exception to this are exceptions like egw_exception_assertion_fails, egw_exception_wrong_parameter
- * or egw_exception_db, which are suppost to happen only during program development.
- */
-class egw_exception extends Exception
-{
- // nothing fancy yet
- function __construct($msg=null,$code=100,Exception $previous=null)
- {
- return parent::__construct($msg, $code, $previous);
- }
-}
+namespace EGroupware\Api\Db\Exception;
-/**
- * Base class for all exceptions about missing permissions
- *
- */
-class egw_exception_no_permission extends egw_exception
-{
- /**
- * Constructor
- *
- * @param string $msg =null message, default "Permission denied!"
- * @param int $code =100 numerical code, default 100
- */
- function __construct($msg=null,$code=100)
- {
- if (is_null($msg)) $msg = lang('Permisson denied!');
-
- parent::__construct($msg,$code);
- }
-}
-
-/**
- * User lacks the right to run an application
- *
- */
-class egw_exception_no_permission_app extends egw_exception_no_permission
-{