Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
+24
-19
@@ -11,39 +11,44 @@
|
||||
namespace IPS\Db;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use RuntimeException;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception class for database errors
|
||||
*/
|
||||
class _Exception extends \RuntimeException
|
||||
class Exception extends RuntimeException
|
||||
{
|
||||
/**
|
||||
* @brief Query
|
||||
*/
|
||||
public $query;
|
||||
public ?string $query = NULL;
|
||||
|
||||
/**
|
||||
* @brief Binds
|
||||
*/
|
||||
public $binds = array();
|
||||
|
||||
public array $binds = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $message MySQL Error message
|
||||
* @param int $code MySQL Error Code
|
||||
* @param \Exception|NULL $previous Previous Exception
|
||||
* @param string|NULL $query MySQL Query that caused exception
|
||||
* @param array $binds Binds for query
|
||||
* @return void
|
||||
* @see <a href='https://bugs.php.net/bug.php?id=30471'>Recursion "bug" with var_export()</a>
|
||||
* @param string|null $message MySQL Error message
|
||||
* @param int $code MySQL Error Code
|
||||
* @param mixed $previous Previous Exception
|
||||
* @param mixed|null $query MySQL Query that caused exception
|
||||
* @param array $binds Binds for query
|
||||
* @see <a href='https://bugs.php.net/bug.php?id=30471'>Recursion "bug" with var_export()</a>
|
||||
*/
|
||||
public function __construct( $message = null, $code = 0, $previous = null, $query=NULL, $binds=array() )
|
||||
public function __construct( string $message=NULL, int $code = 0, mixed $previous=NULL, mixed $query=NULL, array $binds=array() )
|
||||
{
|
||||
/* Store these for the extraLogData() method */
|
||||
$this->query = $query;
|
||||
@@ -57,10 +62,10 @@ class _Exception extends \RuntimeException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isServerError()
|
||||
public function isServerError(): bool
|
||||
{
|
||||
/* Low-end server errors */
|
||||
if ( $this->getCode() < 1046 or \in_array( $this->getCode(), array( 1129, 1130, 1194, 1195, 1203 ) ) )
|
||||
if ( $this->getCode() < 1046 or in_array( $this->getCode(), array( 1129, 1130, 1194, 1195, 1203 ) ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -83,10 +88,10 @@ class _Exception extends \RuntimeException
|
||||
/**
|
||||
* Additional log data?
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function extraLogData()
|
||||
public function extraLogData(): ?string
|
||||
{
|
||||
return \IPS\Db::_replaceBinds( $this->query, $this->binds );
|
||||
return Db::_replaceBinds( $this->query, $this->binds );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user