Skip to content

Commit

Permalink
Merge branch 'bcit-ci:develop' into fix-php81-static-usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jamieburchell authored May 16, 2024
2 parents a4ad916 + 3658d73 commit f5fb787
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 33 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test-phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ name: PHPUnit

on: [push, pull_request]

permissions:
contents: read

jobs:
tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
if: "!contains(github.event.head_commit.message, '[ci skip]')"
env:
PHP_INI_VALUES: assert.exception=1, zend.assertions=1
Expand Down
13 changes: 12 additions & 1 deletion readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ interface and logical structure to access these libraries. CodeIgniter lets
you creatively focus on your project by minimizing the amount of code needed
for a given task.

*************
CodeIgniter 3
*************

This repository is for the legacy version, CodeIgniter 3.
`CodeIgniter 4 <https://github.com/codeigniter4/CodeIgniter4>`_ is the latest
version of the framework.

CodeIgniter 3 is the legacy version of the framework, intended for use with PHP
5.6+. This version is in maintenance, receiving mostly just security updates.

*******************
Release Information
*******************
Expand Down Expand Up @@ -53,7 +64,7 @@ agreement <https://github.com/bcit-ci/CodeIgniter/blob/develop/user_guide_src/so
Resources
*********

- `User Guide <https://codeigniter.com/docs>`_
- `User Guide <https://codeigniter.com/userguide3/>`_
- `Contributing Guide <https://github.com/bcit-ci/CodeIgniter/blob/develop/contributing.md>`_
- `Language File Translations <https://github.com/bcit-ci/codeigniter3-translations>`_
- `Community Forums <https://forum.codeigniter.com/>`_
Expand Down
2 changes: 1 addition & 1 deletion system/core/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function set_cookie($name, $value = '', $expire = 0, $domain = '', $path
if (is_array($name))
{
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name', 'samesite') as $item)
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'samesite', 'name') as $item)
{
if (isset($name[$item]))
{
Expand Down
4 changes: 2 additions & 2 deletions system/core/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CI_Router {
*
* @var string
*/
public $directory;
public $directory = '';

/**
* Default controller (and method if specific)
Expand Down Expand Up @@ -333,7 +333,7 @@ protected function _set_default_controller()
protected function _validate_request($segments)
{
$c = count($segments);
$directory_override = isset($this->directory);
$directory_override = $this->directory !== '';

// Loop through our segments and return as soon as a controller
// is found or when such a directory doesn't exist
Expand Down
2 changes: 1 addition & 1 deletion system/core/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public function csrf_set_cookie()
header('Set-Cookie: '.$this->_csrf_cookie_name.'='.$this->_csrf_hash
.'; Expires='.gmdate('D, d-M-Y H:i:s T', $expire)
.'; Max-Age='.$this->_csrf_expire
.'; Path='.rawurlencode(config_item('cookie_path'))
.'; Path='.implode('/', array_map('rawurlencode', explode('/', config_item('cookie_path'))))
.($domain === '' ? '' : '; Domain='.$domain)
.($secure_cookie ? '; Secure' : '')
.(config_item('cookie_httponly') ? '; HttpOnly' : '')
Expand Down
6 changes: 3 additions & 3 deletions system/database/DB_query_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,11 @@ protected function _wh($qb_key, $key, $value = NULL, $type = 'AND ', $escape = N
$k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL');
}

${$qb_key} = array('condition' => $prefix.$k, 'value' => $v, 'escape' => $escape);
$this->{$qb_key}[] = ${$qb_key};
$$qb_key = array('condition' => $prefix.$k, 'value' => $v, 'escape' => $escape);
$this->{$qb_key}[] = $$qb_key;
if ($this->qb_caching === TRUE)
{
$this->{$qb_cache_key}[] = ${$qb_key};
$this->{$qb_cache_key}[] = $$qb_key;
$this->qb_cache_exists[] = substr($qb_key, 3);
}

Expand Down
8 changes: 4 additions & 4 deletions system/helpers/captcha_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ function create_captcha($data)
{
$theta += $thetac;
$rad = $radius * ($i / $points);
$x = ($rad * cos($theta)) + $x_axis;
$y = ($rad * sin($theta)) + $y_axis;
$x = round(($rad * cos($theta)) + $x_axis);
$y = round(($rad * sin($theta)) + $y_axis);
$theta += $thetac;
$rad1 = $radius * (($i + 1) / $points);
$x1 = ($rad1 * cos($theta)) + $x_axis;
$y1 = ($rad1 * sin($theta)) + $y_axis;
$x1 = round(($rad1 * cos($theta)) + $x_axis);
$y1 = round(($rad1 * sin($theta)) + $y_axis);
imageline($im, $x, $y, $x1, $y1, $colors['grid']);
$theta -= $thetac;
}
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Cache/drivers/Cache_redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CI_Cache_redis extends CI_Driver
'host' => '127.0.0.1',
'password' => NULL,
'port' => 6379,
'timeout' => 0,
'timeout' => 0.0,
'database' => 0
);

Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ public function create_links()
}

// If something isn't quite right, back to the default base page.
if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
if ( ! ctype_digit((string) $this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
{
$this->cur_page = $base_page;
}
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Session/drivers/Session_redis_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function __construct(&$params)
{
$save_path['password'] = preg_match('#auth=([^\s&]+)#', $matches['options'], $match) ? $match[1] : NULL;
$save_path['database'] = preg_match('#database=(\d+)#', $matches['options'], $match) ? (int) $match[1] : NULL;
$save_path['timeout'] = preg_match('#timeout=(\d+\.\d+)#', $matches['options'], $match) ? (float) $match[1] : NULL;
$save_path['timeout'] = preg_match('#timeout=(\d+\.\d+)#', $matches['options'], $match) ? (float) $match[1] : 0.0;

preg_match('#prefix=([^\s&]+)#', $matches['options'], $match) && $this->_key_prefix = $match[1];
}
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Xmlrpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ public function addScalar($val, $type = 'string')

if ($typeof != 1)
{
echo '<strong>XML_RPC_Values</strong>: not a scalar type (${typeof})<br />';
echo "<strong>XML_RPC_Values</strong>: not a scalar type ($typeof)<br />";
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions system/libraries/Xmlrpcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ public function multicall($m)
*/
public function multicall_error($err)
{
$str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
$code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
$str = is_string($err) ? $this->xmlrpcstr["multicall_$err"] : $err->faultString();
$code = is_string($err) ? $this->xmlrpcerr["multicall_$err"] : $err->faultCode();

$struct['faultCode'] = new XML_RPC_Values($code, 'int');
$struct['faultString'] = new XML_RPC_Values($str, 'string');
Expand Down
6 changes: 3 additions & 3 deletions tests/codeigniter/core/Log_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public function test_configuration()
$enabled = new ReflectionProperty('CI_Log', '_enabled');
$enabled->setAccessible(TRUE);

$this->ci_set_config('log_path', '/root/');
$this->ci_set_config('log_path', $this->ci_readonly_dir->url());
$this->ci_set_config('log_threshold', 'z');
$this->ci_set_config('log_date_format', 'd.m.Y');
$this->ci_set_config('log_filename', '');
$this->ci_set_config('log_file_permissions', '');
$instance = new CI_Log();

$this->assertEquals($path->getValue($instance), '/root/');
$this->assertNotFalse(strpos($path->getValue($instance), 'application/readonly'));
$this->assertEquals($threshold->getValue($instance), 1);
$this->assertEquals($date_fmt->getValue($instance), 'd.m.Y');
$this->assertEquals($filename->getValue($instance), 'log-'.date('Y-m-d').'.php');
Expand All @@ -37,7 +37,7 @@ public function test_configuration()
$this->ci_set_config('log_file_permissions', 0600);
$instance = new CI_Log();

$this->assertEquals($path->getValue($instance), APPPATH.'logs/');
$this->assertEquals($path->getValue($instance), $this->ci_vfs_root->url().'application/logs'.DIRECTORY_SEPARATOR);
$this->assertEquals($threshold->getValue($instance), 0);
$this->assertEquals($date_fmt->getValue($instance), 'Y-m-d H:i:s');
$this->assertEquals($filename->getValue($instance), 'testname.log');
Expand Down
6 changes: 3 additions & 3 deletions tests/codeigniter/core/Security_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ public function test_xss_hash()
// Perform hash
$this->security->xss_hash();

$assertRegExp = class_exists('PHPUnit_Runner_Version')
? 'assertRegExp'
: 'assertMatchesRegularExpression';
$assertRegExp = method_exists($this, 'assertMatchesRegularExpression')
? 'assertMatchesRegularExpression'
: 'assertRegExp';
$this->$assertRegExp('#^[0-9a-f]{32}$#iS', $this->security->xss_hash);
}

Expand Down
9 changes: 7 additions & 2 deletions tests/codeigniter/libraries/Encryption_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ class Encryption_test extends CI_TestCase {
public function set_up()
{
$this->encryption = new Mock_Libraries_Encryption();

if (version_compare(PHP_VERSION, '7.1', '<'))
{
$this->markTestSkipped('Ubuntu-latest OpenSSL is not working correct in some older PHP versions.');
}
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -207,8 +212,8 @@ public function test_initialize_encrypt_decrypt()

$this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));

// Try DES in ECB mode, just for the sake of changing stuff
$this->encryption->initialize(array('cipher' => 'des', 'mode' => 'ecb', 'key' => substr($key, 0, 8)));
// Try DES3 in OFB mode, just for the sake of changing stuff
$this->encryption->initialize(array('cipher' => 'tripledes', 'mode' => 'ofb', 'key' => substr($key, 0, 8)));
$this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
}

Expand Down
2 changes: 2 additions & 0 deletions tests/mocks/ci_testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class CI_TestCase extends \PHPUnit\Framework\TestCase {
public $ci_vfs_root;
public $ci_app_root;
public $ci_base_root;
public $ci_readonly_dir;
protected $ci_instance;
protected static $ci_test_instance;

Expand Down Expand Up @@ -39,6 +40,7 @@ public function setUp()
$this->ci_app_root = vfsStream::newDirectory('application')->at($this->ci_vfs_root);
$this->ci_base_root = vfsStream::newDirectory('system')->at($this->ci_vfs_root);
$this->ci_view_root = vfsStream::newDirectory('views')->at($this->ci_app_root);
$this->ci_readonly_dir = vfsStream::newDirectory('readonly', 555)->at($this->ci_app_root);

if (method_exists($this, 'set_up'))
{
Expand Down
4 changes: 2 additions & 2 deletions user_guide_src/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = '3.2.0-dev'
version = '3.1.14-dev'
# The full version, including alpha/beta/rc tags.
release = '3.2.0-dev'
release = '3.1.14-dev'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
16 changes: 13 additions & 3 deletions user_guide_src/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################
CodeIgniter User Guide
######################
########################
CodeIgniter 3 User Guide
########################

- :doc:`License Agreement <license>`
- :doc:`Change Log <changelog>`
Expand All @@ -9,6 +9,16 @@ CodeIgniter User Guide
:local:
:depth: 2

*************
CodeIgniter 3
*************

CodeIgniter 3 is the legacy version of the framework, intended for use with PHP
5.6+. This version is in maintenance, receiving mostly just security updates.

`CodeIgniter 4 <https://codeigniter.com/user_guide/>`_ is the latest version of
the framework.

*******
Welcome
*******
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/installation/downloads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Downloading CodeIgniter
#######################

- `CodeIgniter v3.2.0-dev (Current version) <https://codeload.github.com/bcit-ci/CodeIgniter/zip/develop>`_
- `CodeIgniter v3.1.14 <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1.14>`_
- `CodeIgniter v3.1.13 <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1.13>`_
- `CodeIgniter v3.1.12 <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1.12>`_
- `CodeIgniter v3.1.11 <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1.11>`_
Expand Down
14 changes: 14 additions & 0 deletions user_guide_src/source/installation/upgrade_3114.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
##############################
Upgrading from 3.1.13 to 3.1.14
##############################

Before performing an update you should take your site offline by
replacing the index.php file with a static one.

Step 1: Update your CodeIgniter files
=====================================

Replace all files and directories in your *system/* directory.

.. note:: If you have any custom developed files in these directories,
please make copies of them first.
1 change: 1 addition & 0 deletions user_guide_src/source/installation/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ upgrading from.
:titlesonly:

Upgrading from 3.1.12+ to 3.2.x <upgrade_320>
Upgrading from 3.1.13 to 3.1.14 <upgrade_3114>
Upgrading from 3.1.12 to 3.1.13 <upgrade_3113>
Upgrading from 3.1.11 to 3.1.12 <upgrade_3112>
Upgrading from 3.1.10 to 3.1.11 <upgrade_3111>
Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/tutorial/news_section.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ so it can be used in all other methods in this controller.
It also loads a collection of :doc:`URL Helper <../helpers/url_helper>`
functions, because we'll use one of them in a view later.

Next, there are two methods to view all news items and one for a specific
Next, there are two methods to view news items: one for all news items and one for a specific
news item. You can see that the ``$slug`` variable is passed to the model's
method in the second method. The model is using this slug to identify the
news item to be returned.
Expand Down

0 comments on commit f5fb787

Please sign in to comment.