Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into 3.1-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
NielBuys committed Dec 20, 2024
2 parents 06399d2 + e7173c9 commit f6de1cf
Show file tree
Hide file tree
Showing 23 changed files with 434 additions and 246 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/test-phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,28 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.3', '8.2', '8.1', '8.0', '7.4']
php: ['8.4', '8.3', '8.2', '8.1', '8.0', '7.4']
DB: [ 'pdo/mysql', 'pdo/pgsql', 'pdo/sqlite', 'mysqli', 'pgsql', 'sqlite' ]
compiler: [ default ]
include:
- php: '8.4'
DB: 'pdo/mysql'
compiler: jit
- php: '8.4'
DB: 'pdo/pgsql'
compiler: jit
- php: '8.4'
DB: 'pdo/sqlite'
compiler: jit
- php: '8.4'
DB: 'mysqli'
compiler: jit
- php: '8.4'
DB: 'pgsql'
compiler: jit
- php: '8.4'
DB: 'sqlite'
compiler: jit
- php: '8.3'
DB: 'pdo/mysql'
compiler: jit
Expand Down Expand Up @@ -141,6 +159,6 @@ jobs:

- name: PHPUnit Test
run: |
php -d error_reporting=E_ALL -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 -d mbstring.internal_encoding=UTF-8 vendor/bin/phpunit --coverage-text --configuration tests/travis/${{ matrix.DB }}.phpunit.xml
php -d error_reporting=E_ALL -d zend.enable_gc=0 -d date.timezone=UTC vendor/bin/phpunit --coverage-text --configuration tests/travis/${{ matrix.DB }}.phpunit.xml
env:
XDEBUG_MODE: coverage
2 changes: 1 addition & 1 deletion build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fi

echo "Running tests ..."

php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 -d mbstring.internal_encoding=UTF-8 vendor/bin/phpunit --coverage-text --configuration tests/travis/sqlite.phpunit.xml
php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 vendor/bin/phpunit --coverage-text --configuration tests/travis/sqlite.phpunit.xml

if [ $? -ne 0 ]
then
Expand Down
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
"description": "Fork of CodeIgniter 3",
"name": "nielbuys/framework",
"type": "project",
"homepage": "https://codeigniter.com",
"homepage": "https://github.com/NielBuys/CodeIgniter",
"license": "MIT",
"config": {
"platform": {
"php": "7.4"
}
},
"support": {
"forum": "http://forum.codeigniter.com/",
"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
"slack": "https://codeigniterchat.slack.com",
"source": "https://github.com/bcit-ci/CodeIgniter"
"issues": "https://github.com/NielBuys/CodeIgniter/issues",
"source": "https://github.com/NielBuys/CodeIgniter"
},
"require": {
"php": ">=7.4"
},
"scripts": {
"test:coverage": [
"@putenv XDEBUG_MODE=coverage",
"phpunit --color=always --coverage-text --configuration tests/travis/sqlite.phpunit.xml"
"phpunit --color=always --coverage-text --configuration tests/phpunit.xml"
],
"post-install-cmd": [
"sed -i s/name{0}/name[0]/ vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStream.php"
Expand All @@ -27,6 +31,6 @@
},
"require-dev": {
"mikey179/vfsstream": "1.6.*",
"phpunit/phpunit": "4.* || 5.* || 9.*"
"phpunit/phpunit": "9.* || 10.* || 11.*"
}
}
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
case 'testing':
case 'production':
ini_set('display_errors', 0);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
break;

default:
Expand Down
9 changes: 2 additions & 7 deletions system/core/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
define('MB_ENABLED', TRUE);
// mbstring.internal_encoding is deprecated starting with PHP 5.6
// and it's usage triggers E_DEPRECATED messages.
@ini_set('mbstring.internal_encoding', $charset);
// @ini_set('mbstring.internal_encoding', $charset);
// This is required for mb_convert_encoding() to strip invalid characters.
// That's utilized by CI_Utf8, but it's also done for consistency with iconv.
mb_substitute_character('none');
Expand All @@ -267,18 +267,13 @@
define('ICONV_ENABLED', TRUE);
// iconv.internal_encoding is deprecated starting with PHP 5.6
// and it's usage triggers E_DEPRECATED messages.
@ini_set('iconv.internal_encoding', $charset);
// @ini_set('iconv.internal_encoding', $charset);
}
else
{
define('ICONV_ENABLED', FALSE);
}

if (is_php('5.6'))
{
ini_set('php.internal_encoding', $charset);
}

/*
* ------------------------------------------------------
* Load compatibility features
Expand Down
3 changes: 1 addition & 2 deletions system/core/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class CI_Exceptions {
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice'
E_USER_NOTICE => 'User Notice'
);

/**
Expand Down
38 changes: 24 additions & 14 deletions system/database/DB_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,20 @@ abstract class CI_DB_driver {
*/
protected $_like_escape_chr = '!';

/**
* RegExp used to escape identifiers
*
* @var array
*/
protected $_preg_escape_char = array();

/**
* RegExp used to get operators
*
* @var string[]
*/
protected $_preg_operators = array();

/**
* ORDER BY random keyword
*
Expand Down Expand Up @@ -1410,18 +1424,16 @@ public function escape_identifiers($item)
return $item;
}
// Avoid breaking functions and literal values inside queries
elseif (ctype_digit($item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE)
elseif (ctype_digit((string) $item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE)
{
return $item;
}

static $preg_ec = array();

if (empty($preg_ec))
if (empty($this->_preg_escape_char))
{
if (is_array($this->_escape_char))
{
$preg_ec = array(
$this->_preg_escape_char = array(
preg_quote($this->_escape_char[0], '/'),
preg_quote($this->_escape_char[1], '/'),
$this->_escape_char[0],
Expand All @@ -1430,20 +1442,20 @@ public function escape_identifiers($item)
}
else
{
$preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char, '/');
$preg_ec[2] = $preg_ec[3] = $this->_escape_char;
$this->_preg_escape_char[0] = $this->_preg_escape_char[1] = preg_quote($this->_escape_char, '/');
$this->_preg_escape_char[2] = $this->_preg_escape_char[3] = $this->_escape_char;
}
}

foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
return preg_replace('/'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?\./i', $preg_ec[2].'$1'.$preg_ec[3].'.', $item);
return preg_replace('/'.$this->_preg_escape_char[0].'?([^'.$this->_preg_escape_char[1].'\.]+)'.$this->_preg_escape_char[1].'?\./i', $this->_preg_escape_char[2].'$1'.$this->_preg_escape_char[3].'.', $item);
}
}

return preg_replace('/'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?(\.)?/i', $preg_ec[2].'$1'.$preg_ec[3].'$2', $item);
return preg_replace('/'.$this->_preg_escape_char[0].'?([^'.$this->_preg_escape_char[1].'\.]+)'.$this->_preg_escape_char[1].'?(\.)?/i', $this->_preg_escape_char[2].'$1'.$this->_preg_escape_char[3].'$2', $item);
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -1562,14 +1574,12 @@ protected function _has_operator($str)
*/
protected function _get_operator($str)
{
static $_operators;

if (empty($_operators))
if (empty($this->_preg_operators))
{
$_les = ($this->_like_escape_str !== '')
? '\s+'.preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)), '/')
: '';
$_operators = array(
$this->_preg_operators = array(
'\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
'\s*<>?\s*', // <, <>
'\s*>\s*', // >
Expand All @@ -1587,7 +1597,7 @@ protected function _get_operator($str)

}

return preg_match('/'.implode('|', $_operators).'/i', $str, $match)
return preg_match('/'.implode('|', $this->_preg_operators).'/i', $str, $match)
? $match[0] : FALSE;
}

Expand Down
17 changes: 11 additions & 6 deletions system/database/DB_query_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
*/
protected $qb_cache_no_escape = array();

/**
* Strings that determine if a string represents a literal value or a field name
*
* @var string[]
*/
protected $is_literal_str = array();

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

/**
Expand Down Expand Up @@ -2710,20 +2717,18 @@ protected function _is_literal($str)
{
$str = trim($str);

if (empty($str) OR ctype_digit($str) OR (string) (float) $str === $str OR in_array(strtoupper($str), array('TRUE', 'FALSE'), TRUE))
if (empty($str) OR ctype_digit((string) $str) OR (string) (float) $str === $str OR in_array(strtoupper($str), array('TRUE', 'FALSE'), TRUE))
{
return TRUE;
}

static $_str;

if (empty($_str))
if (empty($this->is_literal_str))
{
$_str = ($this->_escape_char !== '"')
$this->is_literal_str = ($this->_escape_char !== '"')
? array('"', "'") : array("'");
}

return in_array($str[0], $_str, TRUE);
return in_array($str[0], $this->is_literal_str, TRUE);
}

// --------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions system/database/drivers/oci8/oci8_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function __construct($params)
return;
}
elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE
&& (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== ''))
&& (( ! empty($this->port) && ctype_digit((string) $this->port)) OR $this->database !== ''))
{
/* If the hostname field isn't empty, doesn't contain
* ':' and/or '/' and if port and/or database aren't
Expand All @@ -189,7 +189,7 @@ public function __construct($params)
* that the database field is a service name.
*/
$this->dsn = $this->hostname
.(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '')
.(( ! empty($this->port) && ctype_digit((string) $this->port)) ? ':'.$this->port : '')
.($this->database !== '' ? '/'.ltrim($this->database, '/') : '');

if (preg_match($valid_dsns['ec'], $this->dsn))
Expand Down
2 changes: 1 addition & 1 deletion system/database/drivers/postgre/postgre_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function _build_dsn()

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

if ( ! empty($this->port) && ctype_digit($this->port))
if ( ! empty($this->port) && ctype_digit((string) $this->port))
{
$this->dsn .= 'port='.$this->port.' ';
}
Expand Down
4 changes: 2 additions & 2 deletions system/libraries/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public function create_key($length)
* @param array $params Input parameters
* @return string
*/
public function encrypt($data, array $params = NULL)
public function encrypt($data, ?array $params = NULL)
{
if (($params = $this->_get_params($params)) === FALSE)
{
Expand Down Expand Up @@ -504,7 +504,7 @@ protected function _openssl_encrypt($data, $params)
* @param array $params Input parameters
* @return string
*/
public function decrypt($data, array $params = NULL)
public function decrypt($data, ?array $params = NULL)
{
if (($params = $this->_get_params($params)) === FALSE)
{
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Form_validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ public function valid_url($str)

// Apparently, FILTER_VALIDATE_URL doesn't reject digit-only names for some reason ...
// See https://github.com/bcit-ci/CodeIgniter/issues/5755
if (ctype_digit($str))
if (ctype_digit((string) $str))
{
return FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Image_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ public function initialize($props = array())
// Set the quality
$this->quality = trim(str_replace('%', '', $this->quality));

if ($this->quality === '' OR $this->quality === 0 OR ! ctype_digit($this->quality))
if ($this->quality === '' OR $this->quality === 0 OR ! ctype_digit((string) $this->quality))
{
$this->quality = 90;
}
Expand Down
Loading

0 comments on commit f6de1cf

Please sign in to comment.