Skip to content

Commit a39221a

Browse files
committed
fix: cast ctype_digit() arguments to string to resolve PHP 8.1+ deprecation notice. Fix #41.
1 parent dca1348 commit a39221a

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

system/database/DB_driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ public function escape_identifiers($item, $split = TRUE)
13491349
return $item;
13501350
}
13511351
// Avoid breaking functions and literal values inside queries
1352-
elseif (ctype_digit($item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE)
1352+
elseif (ctype_digit((string) $item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE)
13531353
{
13541354
return $item;
13551355
}

system/database/drivers/oci8/oci8_driver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function __construct($params)
177177
return;
178178
}
179179
elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE
180-
&& (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== ''))
180+
&& (( ! empty($this->port) && ctype_digit((string) $this->port)) OR $this->database !== ''))
181181
{
182182
/* If the hostname field isn't empty, doesn't contain
183183
* ':' and/or '/' and if port and/or database aren't
@@ -187,7 +187,7 @@ public function __construct($params)
187187
* that the database field is a service name.
188188
*/
189189
$this->dsn = $this->hostname
190-
.(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '')
190+
.(( ! empty($this->port) && ctype_digit((string) $this->port)) ? ':'.$this->port : '')
191191
.($this->database !== '' ? '/'.ltrim($this->database, '/') : '');
192192

193193
if (preg_match($valid_dsns['ec'], $this->dsn))

system/database/drivers/postgre/postgre_driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function _build_dsn()
9595

9696
$this->hostname === '' OR $this->dsn = 'host='.$this->hostname.' ';
9797

98-
if ( ! empty($this->port) && ctype_digit($this->port))
98+
if ( ! empty($this->port) && ctype_digit((string) $this->port))
9999
{
100100
$this->dsn .= 'port='.$this->port.' ';
101101
}

0 commit comments

Comments
 (0)