Skip to content

Commit

Permalink
BaseConnection details should be protected so they don't get displaye…
Browse files Browse the repository at this point in the history
…d on errors. Fixes #935
  • Loading branch information
lonnieezell committed Feb 12, 2018
1 parent 877767e commit c9e159d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
51 changes: 31 additions & 20 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,71 +49,71 @@ abstract class BaseConnection implements ConnectionInterface
*
* @var string
*/
public $DSN;
protected $DSN;

/**
* Database port
*
* @var int
*/
public $port = '';
protected $port = '';

/**
* Hostname
*
* @var string
*/
public $hostname;
protected $hostname;

/**
* Username
*
* @var string
*/
public $username;
protected $username;

/**
* Password
*
* @var string
*/
public $password;
protected $password;

/**
* Database name
*
* @var string
*/
public $database;
protected $database;

/**
* Database driver
*
* @var string
*/
public $DBDriver = 'MySQLi';
protected $DBDriver = 'MySQLi';

/**
* Sub-driver
*
* @used-by CI_DB_pdo_driver
* @var string
*/
public $subdriver;
protected $subdriver;

/**
* Table prefix
*
* @var string
*/
public $DBPrefix = '';
protected $DBPrefix = '';

/**
* Persistent connection flag
*
* @var bool
*/
public $pConnect = false;
protected $pConnect = false;

/**
* Debug flag
Expand All @@ -122,56 +122,56 @@ abstract class BaseConnection implements ConnectionInterface
*
* @var bool
*/
public $DBDebug = false;
protected $DBDebug = false;

/**
* Should we cache results?
*
* @var bool
*/
public $cacheOn = false;
protected $cacheOn = false;

/**
* Path to store cache files.
*
* @var string
*/
public $cacheDir;
protected $cacheDir;

/**
* Character set
*
* @var string
*/
public $charset = 'utf8';
protected $charset = 'utf8';

/**
* Collation
*
* @var string
*/
public $DBCollat = 'utf8_general_ci';
protected $DBCollat = 'utf8_general_ci';

/**
* Swap Prefix
*
* @var string
*/
public $swapPre = '';
protected $swapPre = '';

/**
* Encryption flag/data
*
* @var mixed
*/
public $encrypt = false;
protected $encrypt = false;

/**
* Compression flag
*
* @var bool
*/
public $compress = false;
protected $compress = false;

/**
* Strict ON flag
Expand All @@ -180,14 +180,14 @@ abstract class BaseConnection implements ConnectionInterface
*
* @var bool
*/
public $strictOn;
protected $strictOn;

/**
* Settings for a failover connection.
*
* @var array
*/
public $failover = [];
protected $failover = [];

//--------------------------------------------------------------------

Expand Down Expand Up @@ -1740,4 +1740,15 @@ abstract protected function _listTables($constrainByPrefix = false): string;
abstract protected function _listColumns(string $table = ''): string;

//--------------------------------------------------------------------

public function __get($key)
{
if (property_exists($this, $key))
{
return $this->$key;
}
}

//--------------------------------------------------------------------

}
4 changes: 3 additions & 1 deletion system/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public function load(array $params = [], string $alias)
throw new \InvalidArgumentException('You have not selected a database type to connect to.');
}

$className = strpos($params['DBDriver'], '\\') === false ? '\CodeIgniter\Database\\' . $params['DBDriver'] . '\\Connection' : $params['DBDriver'] . '\\Connection';
$className = strpos($params['DBDriver'], '\\') === false
? '\CodeIgniter\Database\\' . $params['DBDriver'] . '\\Connection'
: $params['DBDriver'] . '\\Connection';

$class = new $className($params);

Expand Down
12 changes: 6 additions & 6 deletions system/HTTP/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class Response extends Message implements ResponseInterface
// 1xx: Informational
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing', // http://www.iana.org/go/rfc2518
103 => 'Early Hints', // http://www.ietf.org/rfc/rfc8297.txt
102 => 'Processing', // http://www.iana.org/go/rfc2518
103 => 'Early Hints', // http://www.ietf.org/rfc/rfc8297.txt
// 2xx: Success
200 => 'OK',
201 => 'Created',
Expand Down Expand Up @@ -124,8 +124,8 @@ class Response extends Message implements ResponseInterface
428 => 'Precondition Required', // 1.1; http://www.ietf.org/rfc/rfc6585.txt
429 => 'Too Many Requests', // 1.1; http://www.ietf.org/rfc/rfc6585.txt
431 => 'Request Header Fields Too Large', // 1.1; http://www.ietf.org/rfc/rfc6585.txt
451 => 'Unavailable For Legal Reasons', // http://tools.ietf.org/html/rfc7725
499 => 'Client Closed Request', // http://lxr.nginx.org/source/src/http/ngx_http_request.h#0133
451 => 'Unavailable For Legal Reasons', // http://tools.ietf.org/html/rfc7725
499 => 'Client Closed Request', // http://lxr.nginx.org/source/src/http/ngx_http_request.h#0133
// 5xx: Server error
500 => 'Internal Server Error',
501 => 'Not Implemented',
Expand All @@ -137,8 +137,8 @@ class Response extends Message implements ResponseInterface
507 => 'Insufficient Storage', // http://www.iana.org/go/rfc4918
508 => 'Loop Detected', // http://www.iana.org/go/rfc5842
510 => 'Not Extended', // http://www.ietf.org/rfc/rfc2774.txt
511 => 'Network Authentication Required', // http://www.ietf.org/rfc/rfc6585.txt
599 => 'Network Connect Timeout Error', // https://httpstatuses.com/599
511 => 'Network Authentication Required', // http://www.ietf.org/rfc/rfc6585.txt
599 => 'Network Connect Timeout Error', // https://httpstatuses.com/599
];

/**
Expand Down

0 comments on commit c9e159d

Please sign in to comment.